diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-05-20 08:48:18 -0400 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2011-03-29 16:03:50 +0200 |
commit | 99941eb92b2fa5b6c80649abc36b159802241088 (patch) | |
tree | 4e7a016ce4a2b755946e82342a4deca1ce0524bf | |
parent | 1d33474dad5a101666044f58a00f33bd6a134080 (diff) | |
download | samba-99941eb92b2fa5b6c80649abc36b159802241088.tar.gz samba-99941eb92b2fa5b6c80649abc36b159802241088.tar.bz2 samba-99941eb92b2fa5b6c80649abc36b159802241088.zip |
s3:spoolssd Add skeleton for spoolss daemon
Signed-off-by: Günther Deschner <gd@samba.org>
-rw-r--r-- | source3/Makefile.in | 2 | ||||
-rw-r--r-- | source3/printing/spoolssd.c | 83 |
2 files changed, 84 insertions, 1 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 565e52c056..b2f4594f2c 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -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 index 0000000000..00f360f531 --- /dev/null +++ b/source3/printing/spoolssd.c @@ -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); +} |