s3-rpc_server: Use rpc_service_mode() in np_open()
authorSimo Sorce <idra@samba.org>
Wed, 10 Aug 2011 20:13:42 +0000 (16:13 -0400)
committerSimo Sorce <idra@samba.org>
Sun, 21 Aug 2011 13:05:03 +0000 (09:05 -0400)
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
source3/rpc_server/srv_pipe_hnd.c

index 5c906561c097053a2bbdd178084bf0ff1eaafc54..3616922b9bfe8cc4336318c0ff71f9a4a695ede5 100644 (file)
@@ -27,6 +27,7 @@
 #include "rpc_server/srv_pipe_hnd.h"
 #include "rpc_server/srv_pipe.h"
 #include "rpc_server/rpc_server.h"
+#include "rpc_server/rpc_config.h"
 #include "../lib/tsocket/tsocket.h"
 #include "../lib/util/tevent_ntstatus.h"
 
@@ -415,10 +416,10 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
                 struct messaging_context *msg_ctx,
                 struct fake_file_handle **phandle)
 {
-       const char *rpcsrv_type;
+       enum rpc_service_mode_e pipe_mode;
        const char **proxy_list;
        struct fake_file_handle *handle;
-       bool external = false;
+       struct ndr_syntax_id syntax;
 
        proxy_list = lp_parm_string_list(-1, "np", "proxy", NULL);
 
@@ -429,43 +430,42 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
 
        /* Check what is the server type for this pipe.
           Defaults to "embedded" */
-       rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
-                                          "rpc_server", name,
-                                          "embedded");
-       if (strcasecmp_m(rpcsrv_type, "external") == 0 ||
-           strcasecmp_m(rpcsrv_type, "daemon") == 0) {
-               external = true;
-       }
+       pipe_mode = rpc_service_mode(name);
 
        /* Still support the old method for defining external servers */
        if ((proxy_list != NULL) && str_list_check_ci(proxy_list, name)) {
-               external = true;
+               pipe_mode = RPC_SERVICE_MODE_EXTERNAL;
        }
 
-       if (external) {
-               struct np_proxy_state *p;
+       switch (pipe_mode) {
+       case RPC_SERVICE_MODE_EXTERNAL:
 
-               p = make_external_rpc_pipe_p(handle, name,
+               handle->private_data = (void *)make_external_rpc_pipe_p(
+                                            handle, name,
                                             local_address,
                                             remote_address,
                                             session_info);
 
                handle->type = FAKE_FILE_TYPE_NAMED_PIPE_PROXY;
-               handle->private_data = p;
-       } else {
-               struct pipes_struct *p;
-               struct ndr_syntax_id syntax;
+               break;
+
+       case RPC_SERVICE_MODE_EMBEDDED:
 
                if (!is_known_pipename(name, &syntax)) {
                        TALLOC_FREE(handle);
                        return NT_STATUS_OBJECT_NAME_NOT_FOUND;
                }
 
-               p = make_internal_rpc_pipe_p(handle, &syntax, remote_address,
+               handle->private_data = (void *)make_internal_rpc_pipe_p(
+                                            handle, &syntax, remote_address,
                                             session_info, msg_ctx);
 
                handle->type = FAKE_FILE_TYPE_NAMED_PIPE;
-               handle->private_data = p;
+               break;
+
+       case RPC_SERVICE_MODE_DISABLED:
+               handle->private_data = NULL;
+               break;
        }
 
        if (handle->private_data == NULL) {