s3:rpc_server: Reinitialize dcesrv_context in external spoolssd daemon
authorSamuel Cabrero <scabrero@suse.de>
Tue, 26 Feb 2019 15:58:10 +0000 (16:58 +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/printing/queue_process.c
source3/printing/queue_process.h
source3/printing/spoolssd.c
source3/printing/spoolssd.h
source3/smbd/server.c

index 0b6dc9fca9fec179bea58b38797cf9a15d6bd5b5..56f1b876e6bea145d530b00aab5a8fbfb4b0ac48 100644 (file)
@@ -432,6 +432,7 @@ pid_t start_background_queue(struct tevent_context *ev,
 /* Run before the parent forks */
 bool printing_subsystem_init(struct tevent_context *ev_ctx,
                             struct messaging_context *msg_ctx,
+                            struct dcesrv_context *dce_ctx,
                             bool start_daemons,
                             bool background_queue)
 {
@@ -445,7 +446,7 @@ bool printing_subsystem_init(struct tevent_context *ev_ctx,
        /* start as a separate daemon only if enabled */
        if (start_daemons && rpc_spoolss_daemon() == RPC_DAEMON_FORK) {
 
-               pid = start_spoolssd(ev_ctx, msg_ctx);
+               pid = start_spoolssd(ev_ctx, msg_ctx, dce_ctx);
 
        } else if (start_daemons && background_queue) {
 
index a325f13d3290d7e1b9e635b47456741d0cc720c7..e9d0195b3c4d7ce7e304eeb02bac3ec014a3e66a 100644 (file)
 #ifndef _SOURCE3_PRINTING_QUEUE_PROCESS_H_
 #define _SOURCE3_PRINTING_QUEUE_PROCESS_H_
 
+struct dcesrv_context;
+
 bool printing_subsystem_init(struct tevent_context *ev_ctx,
                             struct messaging_context *msg_ctx,
+                            struct dcesrv_context *dce_ctx,
                             bool start_daemons,
                             bool background_queue);
 void printing_subsystem_update(struct tevent_context *ev_ctx,
index 1328cb43a858bff81e63ed53374b08ea15f62a20..5ebda1160ae1cd406060013e2763eb41444c965f 100644 (file)
@@ -670,7 +670,8 @@ done:
 }
 
 pid_t start_spoolssd(struct tevent_context *ev_ctx,
-                   struct messaging_context *msg_ctx)
+                    struct messaging_context *msg_ctx,
+                    struct dcesrv_context *dce_ctx)
 {
        struct rpc_srv_callbacks spoolss_cb;
        pid_t pid;
@@ -765,6 +766,15 @@ pid_t start_spoolssd(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);
+       }
+
        /* the listening fd must be created before the children are actually
         * forked out. */
        status = spoolssd_create_sockets(ev_ctx, msg_ctx, listen_fds,
index e09fb5ea7bc972625622106952d8773150db4f90..6d59b513cb97eb5921f6b11b61118f710d431d01 100644 (file)
 #include "replace.h"
 #include "messages.h"
 
+struct dcesrv_context;
+
 pid_t start_spoolssd(struct tevent_context *ev_ctx,
-                    struct messaging_context *msg_ctx);
+                    struct messaging_context *msg_ctx,
+                    struct dcesrv_context *dce_ctx);
 
 #endif /* _SOURCE3_PRINTING_SPOOLSSD_H_ */
index 1822f538f55ee538270ebc0473a06e6368ce9b02..3347519ea4f57759279e6f2ebd5131edbb2127b7 100644 (file)
@@ -2120,8 +2120,12 @@ extern void build_options(bool screen);
                if (!lp__disable_spoolss() &&
                    (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) {
                        bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true);
-
-                       if (!printing_subsystem_init(ev_ctx, msg_ctx, true, bgq)) {
+                       bool ok = printing_subsystem_init(ev_ctx,
+                                                         msg_ctx,
+                                                         dce_ctx,
+                                                         true,
+                                                         bgq);
+                       if (!ok) {
                                exit_daemon("Samba failed to init printing subsystem", EACCES);
                        }
                }
@@ -2134,7 +2138,12 @@ extern void build_options(bool screen);
 #endif
        } else if (!lp__disable_spoolss() &&
                   (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) {
-               if (!printing_subsystem_init(ev_ctx, msg_ctx, false, false)) {
+               bool ok = printing_subsystem_init(ev_ctx,
+                                                 msg_ctx,
+                                                 dce_ctx,
+                                                 false,
+                                                 false);
+               if (!ok) {
                        exit(1);
                }
        }