2 Unix SMB/Netbios implementation.
4 Copyright (C) Simo Sorce 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "librpc/gen_ndr/messaging.h"
21 #include "include/printing.h"
22 #include "rpc_server/rpc_server.h"
24 #define SPOOLSS_PIPE_NAME "spoolss"
27 static void spoolss_reopen_logs(void)
32 ret = asprintf(&lfile, "%s.spoolssd", lp_logfile());
34 lp_set_logfile(lfile);
40 static void smb_conf_updated(struct messaging_context *msg,
43 struct server_id server_id,
46 DEBUG(10, ("Got message saying smb.conf was updated. Reloading.\n"));
47 change_to_root_user();
49 spoolss_reopen_logs();
52 void start_spoolssd(void)
58 DEBUG(1, ("Forking SPOOLSS Daemon\n"));
63 DEBUG(0, ("Failed to fork SPOOLSS [%s], aborting ...\n",
76 status = reinit_after_fork(server_messaging_context(),
77 server_event_context(),
79 if (!NT_STATUS_IS_OK(status)) {
80 DEBUG(0,("reinit_after_fork() failed\n"));
81 smb_panic("reinit_after_fork() failed");
84 spoolss_reopen_logs();
86 smbd_setup_sig_term_handler();
87 smbd_setup_sig_hup_handler();
89 if (!serverid_register(procid_self(),
90 FLAG_MSG_GENERAL|FLAG_MSG_SMBD
91 |FLAG_MSG_PRINT_GENERAL)) {
95 if (!locking_init()) {
99 messaging_register(server_messaging_context(), NULL,
100 MSG_PRINTER_UPDATE, print_queue_receive);
101 messaging_register(server_messaging_context(), NULL,
102 MSG_SMB_CONF_UPDATED, smb_conf_updated);
104 if (!setup_named_pipe_socket(SPOOLSS_PIPE_NAME, server_event_context())) {
109 ret = tevent_loop_wait(server_event_context());
111 /* should not be reached */
112 DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
113 ret, (ret == 0) ? "out of events" : strerror(errno)));