s3:spoolssd Add skeleton for spoolss daemon
authorSimo Sorce <ssorce@redhat.com>
Thu, 20 May 2010 12:48:18 +0000 (08:48 -0400)
committerGünther Deschner <gd@samba.org>
Tue, 29 Mar 2011 14:03:50 +0000 (16:03 +0200)
Signed-off-by: Günther Deschner <gd@samba.org>
source3/Makefile.in
source3/printing/spoolssd.c [new file with mode: 0644]

index 565e52c056896a4031d149e37050775598bb94e6..b2f4594f2cb6ca14616c75084744e4fa9bbee575 100644 (file)
@@ -886,7 +886,7 @@ SMBD_OBJ_SRV = smbd/server_reload.o \
                smbd/posix_acls.o lib/sysacls.o \
               smbd/process.o smbd/service.o smbd/error.o \
               rpc_server/epmd.o \
-              printing/printspoolss.o \
+              printing/printspoolss.o printing/spoolssd.o \
               lib/sysquotas.o lib/sysquotas_linux.o \
               lib/sysquotas_xfs.o lib/sysquotas_4A.o \
               lib/sysquotas_nfs.o \
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
new file mode 100644 (file)
index 0000000..00f360f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+   Unix SMB/Netbios implementation.
+   SPOOLSS Daemon
+   Copyright (C) Simo Sorce 2010
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "includes.h"
+#include "librpc/gen_ndr/messaging.h"
+#include "include/printing.h"
+#include "rpc_server/rpc_server.h"
+
+#define SPOOLSS_PIPE_NAME "spoolss"
+
+void start_spoolssd(void)
+{
+       pid_t pid;
+       NTSTATUS status;
+       int ret;
+
+       DEBUG(1, ("Forking SPOOLSS Daemon\n"));
+
+       pid = sys_fork();
+
+       if (pid == -1) {
+               DEBUG(0, ("Failed to fork SPOOLSS [%s], aborting ...\n",
+                          strerror(errno)));
+               exit(1);
+       }
+
+       if (pid) {
+               /* parent */
+               return;
+       }
+
+       /* child */
+       status = reinit_after_fork(server_messaging_context(),
+                                  server_event_context(),
+                                  procid_self(), true);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("reinit_after_fork() failed\n"));
+               smb_panic("reinit_after_fork() failed");
+       }
+
+       smbd_setup_sig_term_handler();
+       smbd_setup_sig_hup_handler();
+
+       if (!serverid_register(procid_self(),
+                               FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+                               |FLAG_MSG_PRINT_GENERAL)) {
+               exit(1);
+       }
+
+       if (!locking_init()) {
+               exit(1);
+       }
+
+       messaging_register(server_messaging_context(), NULL,
+                          MSG_PRINTER_UPDATE, print_queue_receive);
+
+       if (!setup_named_pipe_socket(SPOOLSS_PIPE_NAME, server_event_context())) {
+               exit(1);
+       }
+
+       /* loop forever */
+       ret = tevent_loop_wait(server_event_context());
+
+       /* should not be reached */
+       DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
+                ret, (ret == 0) ? "out of events" : strerror(errno)));
+       exit(1);
+}