s3-rpc_server: Use rpc_service_mode() in rpc_pipe_open_interface()
authorSimo Sorce <idra@samba.org>
Wed, 10 Aug 2011 19:34:37 +0000 (15:34 -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/rpc_ncacn_np.c

index 1080a98eb44a96750ae9b941ee2e13f5e0942cbc..028f182a59393473af11bc84b0524a774c83b872 100644 (file)
@@ -35,6 +35,7 @@
 #include "../lib/tsocket/tsocket.h"
 #include "../lib/util/tevent_ntstatus.h"
 #include "rpc_contexts.h"
+#include "rpc_server/rpc_config.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
@@ -771,7 +772,7 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
                                 struct rpc_pipe_client **cli_pipe)
 {
        struct rpc_pipe_client *cli = NULL;
-       const char *server_type;
+       enum rpc_service_mode_e pipe_mode;
        const char *pipe_name;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
@@ -799,11 +800,10 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
 
        DEBUG(5, ("Connecting to %s pipe.\n", pipe_name));
 
-       server_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
-                                          "rpc_server", pipe_name,
-                                          "embedded");
+       pipe_mode = rpc_service_mode(pipe_name);
 
-       if (strcasecmp_m(server_type, "embedded") == 0) {
+       switch (pipe_mode) {
+       case RPC_SERVICE_MODE_EMBEDDED:
                status = rpc_pipe_open_internal(tmp_ctx,
                                                syntax, session_info,
                                                remote_address, msg_ctx,
@@ -811,8 +811,8 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        goto done;
                }
-       } else if (strcasecmp_m(server_type, "daemon") == 0 ||
-                  strcasecmp_m(server_type, "external") == 0) {
+               break;
+       case RPC_SERVICE_MODE_EXTERNAL:
                /* It would be nice to just use rpc_pipe_open_ncalrpc() but
                 * for now we need to use the special proxy setup to connect
                 * to spoolssd. */
@@ -824,10 +824,11 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        goto done;
                }
-       } else {
+               break;
+       case RPC_SERVICE_MODE_DISABLED:
                status = NT_STATUS_NOT_IMPLEMENTED;
-               DEBUG(0, ("Wrong servertype specified in config file: %s",
-                         nt_errstr(status)));
+               DEBUG(0, ("Service pipe %s is disabled in config file: %s",
+                         pipe_name, nt_errstr(status)));
                goto done;
         }