diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c index 768584b692e..334a433cdca 100644 --- a/source3/rpc_server/epmd.c +++ b/source3/rpc_server/epmd.c @@ -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", diff --git a/source3/rpc_server/epmd.h b/source3/rpc_server/epmd.h index c08ca0978bf..882213ebbf2 100644 --- a/source3/rpc_server/epmd.h +++ b/source3/rpc_server/epmd.h @@ -25,7 +25,10 @@ #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 diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 0ddc9bbd438..63646364238 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -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); }