s3:rpc_server: Reinitialize dcesrv_context in external epmd daemon
authorSamuel Cabrero <scabrero@suse.de>
Tue, 26 Feb 2019 13:18:34 +0000 (14:18 +0100)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 20 Mar 2020 15:36:32 +0000 (15:36 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_server/epmd.c
source3/rpc_server/epmd.h
source3/smbd/server.c

index 768584b692e835f341b91e831429aab88007c4b7..334a433cdca0567023ed33fc60c15ae77e9b6e1a 100644 (file)
@@ -137,7 +137,8 @@ static bool epmapper_shutdown_cb(void *ptr) {
 }
 
 void start_epmd(struct tevent_context *ev_ctx,
-               struct messaging_context *msg_ctx)
+               struct messaging_context *msg_ctx,
+               struct dcesrv_context *dce_ctx)
 {
        struct rpc_srv_callbacks epmapper_cb;
        NTSTATUS status;
@@ -196,6 +197,15 @@ void start_epmd(struct tevent_context *ev_ctx,
                exit(1);
        }
 
+       DBG_INFO("Reinitializing DCE/RPC server context\n");
+
+       status = dcesrv_reinit_context(dce_ctx);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_ERR("Failed to reinit DCE/RPC context: %s\n",
+                       nt_errstr(status));
+               exit(1);
+       }
+
        status = rpc_epmapper_init(&epmapper_cb);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Failed to register epmd rpc interface! (%s)\n",
index c08ca0978bfd098e8e0b8f2b3c988cc53079aa18..882213ebbf209335fdeedba6f1e8ad103ed19f08 100644 (file)
 #include "replace.h"
 #include "messages.h"
 
+struct dcesrv_context;
+
 void start_epmd(struct tevent_context *ev_ctx,
-               struct messaging_context *msg_ctx);
+               struct messaging_context *msg_ctx,
+               struct dcesrv_context *dce_ctx);
 
 #endif
index 0ddc9bbd438a70c0a75b67f103c9fea741b31ee2..63646364238dd1dd5fba5a370d389255ae4d5de7 100644 (file)
@@ -2090,12 +2090,6 @@ extern void build_options(bool screen);
                return -1;
        }
 
-       if (is_daemon && !interactive) {
-               if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) {
-                       start_epmd(ev_ctx, msg_ctx);
-               }
-       }
-
        status = dcesrv_init(ev_ctx, ev_ctx, msg_ctx, dce_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("Failed to setup RPC server: %s\n", nt_errstr(status));
@@ -2111,6 +2105,10 @@ extern void build_options(bool screen);
         *  and we fork a copy of ourselves here */
        if (is_daemon && !interactive) {
 
+               if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) {
+                       start_epmd(ev_ctx, msg_ctx, dce_ctx);
+               }
+
                if (rpc_lsasd_daemon() == RPC_DAEMON_FORK) {
                        start_lsasd(ev_ctx, msg_ctx);
                }