librpc:core: Split dcesrv context init and endpoint servers init
authorSamuel Cabrero <scabrero@suse.de>
Tue, 5 Feb 2019 17:54:02 +0000 (18:54 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Dec 2019 00:35:30 +0000 (00:35 +0000)
The S4 server will initialize the endpoint servers specified in smb.conf,
but the S3 server need to initialize all registered endpoint servers (the
embedded ones).

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/rpc/dcesrv_core.c
librpc/rpc/dcesrv_core.h
source4/rpc_server/service_rpc.c
source4/torture/rpc/spoolss_notify.c

index daa95afcab76a534dc6fa521e5bbcbe68d6357d1..5e548a288d0565b9e59332aca64867156cedd443 100644 (file)
@@ -2320,18 +2320,10 @@ static NTSTATUS dcesrv_process_ncacn_packet(struct dcesrv_connection *dce_conn,
 
 _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
                                      struct loadparm_context *lp_ctx,
-                                     const char **endpoint_servers,
                                      struct dcesrv_context_callbacks *cb,
                                      struct dcesrv_context **_dce_ctx)
 {
-       NTSTATUS status;
        struct dcesrv_context *dce_ctx;
-       int i;
-
-       if (!endpoint_servers) {
-               DEBUG(0,("dcesrv_init_context: no endpoint servers configured\n"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
 
        dce_ctx = talloc_zero(mem_ctx, struct dcesrv_context);
        NT_STATUS_HAVE_NO_MEMORY(dce_ctx);
@@ -2353,6 +2345,21 @@ _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
                dce_ctx->callbacks = *cb;
        }
 
+       *_dce_ctx = dce_ctx;
+       return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcesrv_init_ep_servers(struct dcesrv_context *dce_ctx,
+                                        const char **endpoint_servers)
+{
+       NTSTATUS status;
+       int i;
+
+       if (endpoint_servers == NULL) {
+               DBG_ERR("No endpoint servers configured\n");
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
        for (i=0;endpoint_servers[i];i++) {
                const struct dcesrv_endpoint_server *ep_server;
 
@@ -2370,7 +2377,6 @@ _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
                }
        }
 
-       *_dce_ctx = dce_ctx;
        return NT_STATUS_OK;
 }
 
index 5e47976ced9595cfe646f79042446d20f3438e4b..e5ad652a4e2b0ffd746047e4982d8b568d3690df 100644 (file)
@@ -444,11 +444,12 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                                   const struct dcesrv_interface *iface,
                                   const struct security_descriptor *sd);
 NTSTATUS dcerpc_register_ep_server(const struct dcesrv_endpoint_server *ep_server);
+NTSTATUS dcesrv_init_ep_servers(struct dcesrv_context *dce_ctx,
+                               const char **ep_servers);
 const struct dcesrv_endpoint_server *dcesrv_ep_server_byname(const char *name);
 
 NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
                             struct loadparm_context *lp_ctx,
-                            const char **endpoint_servers,
                             struct dcesrv_context_callbacks *cb,
                             struct dcesrv_context **_dce_ctx);
 
index ef4bfab237aac89b9ed965bb953ee8523cc3ccde..96ebc2dbe576998d2c77ece02735d996117d3eb8 100644 (file)
@@ -129,6 +129,7 @@ static NTSTATUS dcesrv_task_init(struct task_server *task)
 {
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
        struct dcesrv_context *dce_ctx;
+       const char **ep_servers = NULL;
 
        dcerpc_server_init(task->lp_ctx);
 
@@ -136,13 +137,18 @@ static NTSTATUS dcesrv_task_init(struct task_server *task)
 
        status = dcesrv_init_context(task->event_ctx,
                                     task->lp_ctx,
-                                    lpcfg_dcerpc_endpoint_servers(task->lp_ctx),
                                     &srv_callbacks,
                                     &dce_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
 
+       ep_servers = lpcfg_dcerpc_endpoint_servers(task->lp_ctx);
+       status = dcesrv_init_ep_servers(dce_ctx, ep_servers);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
        /* Make sure the directory for NCALRPC exists */
        if (!directory_exist(lpcfg_ncalrpc_dir(task->lp_ctx))) {
                mkdir(lpcfg_ncalrpc_dir(task->lp_ctx), 0755);
index fa2b917c8d9783a4be274c1c24ac375d92087abc..9b183ac49aed2186ea2e04609016fae8321198d4 100644 (file)
@@ -483,11 +483,15 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
                                   address, NULL);
        torture_assert_ntstatus_ok(tctx, status, "starting smb server");
 
-       status = dcesrv_init_context(tctx, tctx->lp_ctx, endpoints,
-                                    &srv_cb, &dce_ctx);
+       status = dcesrv_init_context(tctx, tctx->lp_ctx, &srv_cb, &dce_ctx);
        torture_assert_ntstatus_ok(tctx, status,
                                   "unable to initialize DCE/RPC server");
 
+       status = dcesrv_init_ep_servers(dce_ctx, endpoints);
+       torture_assert_ntstatus_ok(tctx,
+                                  status,
+                                  "unable to initialize DCE/RPC ep servers");
+
        for (e=dce_ctx->endpoint_list;e;e=e->next) {
                status = dcesrv_add_ep(dce_ctx, tctx->lp_ctx,
                                       e, tctx->ev,