1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-22 05:57:43 +03:00

s3:rpc_server: Reinitialize dcesrv_context in external spoolssd daemon

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Samuel Cabrero 2019-02-26 16:58:10 +01:00 committed by Samuel Cabrero
parent 3b52f1543c
commit f89ae36306
5 changed files with 32 additions and 6 deletions

View 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) {

View File

@ -23,8 +23,11 @@
#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,

View 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,

View File

@ -23,7 +23,10 @@
#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_ */

View 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);
}
}