s3: Use dbwrap_parse_record in fetch_share_mode_unlocked
[Samba.git] / source3 / printing / spoolssd.c
blobdb303a1b0bd20ccd0da126d719492fa7602f45c5
1 /*
2 Unix SMB/Netbios implementation.
3 SPOOLSS Daemon
4 Copyright (C) Simo Sorce <idra@samba.org> 2010-2011
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/>.
19 #include "includes.h"
20 #include "serverid.h"
21 #include "smbd/smbd.h"
23 #include "messages.h"
24 #include "include/printing.h"
25 #include "printing/nt_printing_migrate_internal.h"
26 #include "printing/queue_process.h"
27 #include "printing/pcap.h"
28 #include "printing/load.h"
29 #include "ntdomain.h"
30 #include "librpc/gen_ndr/srv_winreg.h"
31 #include "librpc/gen_ndr/srv_spoolss.h"
32 #include "rpc_server/rpc_server.h"
33 #include "rpc_server/rpc_ep_register.h"
34 #include "rpc_server/spoolss/srv_spoolss_nt.h"
35 #include "librpc/rpc/dcerpc_ep.h"
36 #include "lib/server_prefork.h"
37 #include "lib/server_prefork_util.h"
39 #define SPOOLSS_PIPE_NAME "spoolss"
40 #define DAEMON_NAME "spoolssd"
42 static struct server_id parent_id;
43 static struct prefork_pool *spoolss_pool = NULL;
44 static int spoolss_child_id = 0;
46 static struct pf_daemon_config default_pf_spoolss_cfg = {
47 .prefork_status = PFH_INIT,
48 .min_children = 5,
49 .max_children = 25,
50 .spawn_rate = 5,
51 .max_allowed_clients = 100,
52 .child_min_life = 60 /* 1 minute minimum life time */
54 static struct pf_daemon_config pf_spoolss_cfg = { 0 };
56 pid_t start_spoolssd(struct tevent_context *ev_ctx,
57 struct messaging_context *msg_ctx);
59 static void spoolss_reopen_logs(int child_id)
61 char *lfile = lp_logfile(talloc_tos());
62 char *ext;
63 int rc;
65 if (child_id) {
66 rc = asprintf(&ext, "%s.%d", DAEMON_NAME, child_id);
67 } else {
68 rc = asprintf(&ext, "%s", DAEMON_NAME);
71 if (rc == -1) {
72 return;
75 rc = 0;
76 if (lfile == NULL || lfile[0] == '\0') {
77 rc = asprintf(&lfile, "%s/log.%s",
78 get_dyn_LOGFILEBASE(), ext);
79 } else {
80 if (strstr(lfile, ext) == NULL) {
81 if (child_id) {
82 rc = asprintf(&lfile, "%s.%d",
83 lp_logfile(talloc_tos()),
84 child_id);
85 } else {
86 rc = asprintf(&lfile, "%s.%s",
87 lp_logfile(talloc_tos()),
88 ext);
93 if (rc > 0) {
94 lp_set_logfile(lfile);
95 SAFE_FREE(lfile);
98 SAFE_FREE(ext);
100 reopen_logs();
103 static void update_conf(struct tevent_context *ev,
104 struct messaging_context *msg)
106 change_to_root_user();
107 lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
108 load_printers(ev, msg);
110 spoolss_reopen_logs(spoolss_child_id);
111 if (spoolss_child_id == 0) {
112 pfh_daemon_config(DAEMON_NAME,
113 &pf_spoolss_cfg,
114 &default_pf_spoolss_cfg);
115 pfh_manage_pool(ev, msg, &pf_spoolss_cfg, spoolss_pool);
119 static void smb_conf_updated(struct messaging_context *msg,
120 void *private_data,
121 uint32_t msg_type,
122 struct server_id server_id,
123 DATA_BLOB *data)
125 struct tevent_context *ev_ctx = talloc_get_type_abort(private_data,
126 struct tevent_context);
128 DEBUG(10, ("Got message saying smb.conf was updated. Reloading.\n"));
129 update_conf(ev_ctx, msg);
132 static void update_pcap(struct tevent_context *ev_ctx,
133 struct messaging_context *msg_ctx)
135 change_to_root_user();
136 delete_and_reload_printers(ev_ctx, msg_ctx);
139 static void pcap_updated(struct messaging_context *msg,
140 void *private_data,
141 uint32_t msg_type,
142 struct server_id server_id,
143 DATA_BLOB *data)
145 struct tevent_context *ev_ctx;
147 ev_ctx = talloc_get_type_abort(private_data, struct tevent_context);
149 DEBUG(10, ("Got message that pcap updated. Reloading.\n"));
150 update_pcap(ev_ctx, msg);
153 static void spoolss_sig_term_handler(struct tevent_context *ev,
154 struct tevent_signal *se,
155 int signum,
156 int count,
157 void *siginfo,
158 void *private_data)
160 exit_server_cleanly("termination signal");
163 static void spoolss_setup_sig_term_handler(struct tevent_context *ev_ctx)
165 struct tevent_signal *se;
167 se = tevent_add_signal(ev_ctx,
168 ev_ctx,
169 SIGTERM, 0,
170 spoolss_sig_term_handler,
171 NULL);
172 if (!se) {
173 exit_server("failed to setup SIGTERM handler");
177 static void spoolss_sig_hup_handler(struct tevent_context *ev,
178 struct tevent_signal *se,
179 int signum,
180 int count,
181 void *siginfo,
182 void *pvt)
184 struct messaging_context *msg_ctx;
186 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
188 DEBUG(1,("Reloading printers after SIGHUP\n"));
189 update_conf(ev, msg_ctx);
191 /* relay to all children */
192 if (spoolss_pool) {
193 prefork_send_signal_to_all(spoolss_pool, SIGHUP);
197 static void spoolss_setup_sig_hup_handler(struct tevent_context *ev_ctx,
198 struct messaging_context *msg_ctx)
200 struct tevent_signal *se;
202 se = tevent_add_signal(ev_ctx,
203 ev_ctx,
204 SIGHUP, 0,
205 spoolss_sig_hup_handler,
206 msg_ctx);
207 if (!se) {
208 exit_server("failed to setup SIGHUP handler");
212 static bool spoolss_init_cb(void *ptr)
214 struct messaging_context *msg_ctx = talloc_get_type_abort(
215 ptr, struct messaging_context);
217 return nt_printing_tdb_migrate(msg_ctx);
220 static bool spoolss_shutdown_cb(void *ptr)
222 srv_spoolss_cleanup();
224 return true;
227 /* Children */
229 static void spoolss_chld_sig_hup_handler(struct tevent_context *ev,
230 struct tevent_signal *se,
231 int signum,
232 int count,
233 void *siginfo,
234 void *pvt)
236 struct messaging_context *msg_ctx;
238 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
240 change_to_root_user();
241 DEBUG(1,("Reloading printers after SIGHUP\n"));
242 load_printers(ev, msg_ctx);
243 spoolss_reopen_logs(spoolss_child_id);
246 static bool spoolss_setup_chld_hup_handler(struct tevent_context *ev_ctx,
247 struct messaging_context *msg_ctx,
248 struct pf_worker_data *pf)
250 struct tevent_signal *se;
252 se = tevent_add_signal(ev_ctx,
253 ev_ctx,
254 SIGHUP, 0,
255 spoolss_chld_sig_hup_handler,
256 msg_ctx);
257 if (!se) {
258 DEBUG(1, ("failed to setup SIGHUP handler"));
259 return false;
262 return true;
265 static void parent_ping(struct messaging_context *msg_ctx,
266 void *private_data,
267 uint32_t msg_type,
268 struct server_id server_id,
269 DATA_BLOB *data)
272 /* The fact we received this message is enough to let make the event
273 * loop if it was idle. spoolss_children_main will cycle through
274 * spoolss_next_client at least once. That function will take whatever
275 * action is necessary */
277 DEBUG(10, ("Got message that the parent changed status.\n"));
278 return;
281 static bool spoolss_child_init(struct tevent_context *ev_ctx,
282 int child_id, struct pf_worker_data *pf)
284 NTSTATUS status;
285 struct rpc_srv_callbacks spoolss_cb;
286 struct messaging_context *msg_ctx = messaging_init(NULL, ev_ctx);
287 bool ok;
289 status = reinit_after_fork(msg_ctx, ev_ctx,
290 true);
291 if (!NT_STATUS_IS_OK(status)) {
292 DEBUG(0,("reinit_after_fork() failed\n"));
293 smb_panic("reinit_after_fork() failed");
296 spoolss_child_id = child_id;
297 spoolss_reopen_logs(child_id);
299 ok = spoolss_setup_chld_hup_handler(ev_ctx, msg_ctx, pf);
300 if (!ok) {
301 return false;
304 if (!serverid_register(messaging_server_id(msg_ctx),
305 FLAG_MSG_GENERAL |
306 FLAG_MSG_PRINT_GENERAL)) {
307 return false;
310 if (!locking_init()) {
311 return false;
314 messaging_register(msg_ctx, ev_ctx,
315 MSG_SMB_CONF_UPDATED, smb_conf_updated);
316 messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
317 pcap_updated);
318 messaging_register(msg_ctx, ev_ctx,
319 MSG_PREFORK_PARENT_EVENT, parent_ping);
321 /* As soon as messaging is up check if pcap has been loaded already.
322 * If so then we probably missed a message and should load_printers()
323 * ourselves. If pcap has not been loaded yet, then ignore, we will get
324 * a message as soon as the bq process completes the reload. */
325 if (pcap_cache_loaded()) {
326 load_printers(ev_ctx, msg_ctx);
329 /* try to reinit rpc queues */
330 spoolss_cb.init = spoolss_init_cb;
331 spoolss_cb.shutdown = spoolss_shutdown_cb;
332 spoolss_cb.private_data = msg_ctx;
334 status = rpc_winreg_init(NULL);
335 if (!NT_STATUS_IS_OK(status)) {
336 DEBUG(0, ("Failed to register winreg rpc inteface! (%s)\n",
337 nt_errstr(status)));
338 return false;
341 status = rpc_spoolss_init(&spoolss_cb);
342 if (!NT_STATUS_IS_OK(status)) {
343 DEBUG(0, ("Failed to register spoolss rpc inteface! (%s)\n",
344 nt_errstr(status)));
345 return false;
348 return true;
351 struct spoolss_children_data {
352 struct tevent_context *ev_ctx;
353 struct messaging_context *msg_ctx;
354 struct pf_worker_data *pf;
355 int listen_fd_size;
356 int *listen_fds;
359 static void spoolss_next_client(void *pvt);
361 static int spoolss_children_main(struct tevent_context *ev_ctx,
362 struct messaging_context *msg_ctx,
363 struct pf_worker_data *pf,
364 int child_id,
365 int listen_fd_size,
366 int *listen_fds,
367 void *private_data)
369 struct spoolss_children_data *data;
370 bool ok;
371 int ret;
373 ok = spoolss_child_init(ev_ctx, child_id, pf);
374 if (!ok) {
375 return 1;
378 data = talloc(ev_ctx, struct spoolss_children_data);
379 if (!data) {
380 return 1;
382 data->pf = pf;
383 data->ev_ctx = ev_ctx;
384 data->msg_ctx = msg_ctx;
385 data->listen_fd_size = listen_fd_size;
386 data->listen_fds = listen_fds;
388 /* loop until it is time to exit */
389 while (pf->status != PF_WORKER_EXITING) {
390 /* try to see if it is time to schedule the next client */
391 spoolss_next_client(data);
393 ret = tevent_loop_once(ev_ctx);
394 if (ret != 0) {
395 DEBUG(0, ("tevent_loop_once() exited with %d: %s\n",
396 ret, strerror(errno)));
397 pf->status = PF_WORKER_EXITING;
401 return ret;
404 static void spoolss_client_terminated(void *pvt)
406 struct spoolss_children_data *data;
408 data = talloc_get_type_abort(pvt, struct spoolss_children_data);
410 pfh_client_terminated(data->pf);
412 spoolss_next_client(pvt);
415 struct spoolss_new_client {
416 struct spoolss_children_data *data;
417 struct tsocket_address *srv_addr;
418 struct tsocket_address *cli_addr;
421 static void spoolss_handle_client(struct tevent_req *req);
423 static void spoolss_next_client(void *pvt)
425 struct tevent_req *req;
426 struct spoolss_children_data *data;
427 struct spoolss_new_client *next;
429 data = talloc_get_type_abort(pvt, struct spoolss_children_data);
431 if (!pfh_child_allowed_to_accept(data->pf)) {
432 /* nothing to do for now we are already listening
433 * or we are not allowed to listen further */
434 return;
437 next = talloc_zero(data, struct spoolss_new_client);
438 if (!next) {
439 DEBUG(1, ("Out of memory!?\n"));
440 return;
442 next->data = data;
444 req = prefork_listen_send(next, data->ev_ctx, data->pf,
445 data->listen_fd_size,
446 data->listen_fds);
447 if (!req) {
448 DEBUG(1, ("Failed to make listening request!?\n"));
449 talloc_free(next);
450 return;
452 tevent_req_set_callback(req, spoolss_handle_client, next);
455 static void spoolss_handle_client(struct tevent_req *req)
457 struct spoolss_children_data *data;
458 struct spoolss_new_client *client;
459 const DATA_BLOB ping = data_blob_null;
460 int ret;
461 int sd;
463 client = tevent_req_callback_data(req, struct spoolss_new_client);
464 data = client->data;
466 ret = prefork_listen_recv(req, client, &sd,
467 &client->srv_addr, &client->cli_addr);
469 /* this will free the request too */
470 talloc_free(client);
472 if (ret != 0) {
473 DEBUG(6, ("No client connection was available after all!\n"));
474 return;
477 /* Warn parent that our status changed */
478 messaging_send(data->msg_ctx, parent_id,
479 MSG_PREFORK_CHILD_EVENT, &ping);
481 DEBUG(2, ("Spoolss preforked child %d got client connection!\n",
482 (int)(data->pf->pid)));
484 named_pipe_accept_function(data->ev_ctx, data->msg_ctx,
485 SPOOLSS_PIPE_NAME, sd,
486 spoolss_client_terminated, data);
489 /* ==== Main Process Functions ==== */
491 extern pid_t background_lpq_updater_pid;
492 static char *bq_logfile;
494 static void check_updater_child(struct tevent_context *ev_ctx,
495 struct messaging_context *msg_ctx)
497 int status;
498 pid_t pid;
500 if (background_lpq_updater_pid == -1) {
501 return;
504 pid = sys_waitpid(background_lpq_updater_pid, &status, WNOHANG);
505 if (pid > 0) {
506 DEBUG(2, ("The background queue child died... Restarting!\n"));
507 pid = start_background_queue(ev_ctx, msg_ctx, bq_logfile);
508 background_lpq_updater_pid = pid;
512 static void child_ping(struct messaging_context *msg_ctx,
513 void *private_data,
514 uint32_t msg_type,
515 struct server_id server_id,
516 DATA_BLOB *data)
518 struct tevent_context *ev_ctx;
520 ev_ctx = talloc_get_type_abort(private_data, struct tevent_context);
522 DEBUG(10, ("Got message that a child changed status.\n"));
523 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
526 static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
527 struct messaging_context *msg_ctx,
528 struct timeval current_time);
529 static void spoolssd_check_children(struct tevent_context *ev_ctx,
530 struct tevent_timer *te,
531 struct timeval current_time,
532 void *pvt);
534 static void spoolssd_sigchld_handler(struct tevent_context *ev_ctx,
535 struct prefork_pool *pfp,
536 void *pvt)
538 struct messaging_context *msg_ctx;
540 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
542 /* run pool management so we can fork/retire or increase
543 * the allowed connections per child based on load */
544 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
546 /* also check if the updater child is alive and well */
547 check_updater_child(ev_ctx, msg_ctx);
550 static bool spoolssd_setup_children_monitor(struct tevent_context *ev_ctx,
551 struct messaging_context *msg_ctx)
553 bool ok;
555 /* add our oun sigchld callback */
556 prefork_set_sigchld_callback(spoolss_pool,
557 spoolssd_sigchld_handler, msg_ctx);
559 ok = spoolssd_schedule_check(ev_ctx, msg_ctx,
560 tevent_timeval_current());
561 return ok;
564 static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
565 struct messaging_context *msg_ctx,
566 struct timeval current_time)
568 struct tevent_timer *te;
569 struct timeval next_event;
571 /* check situation again in 10 seconds */
572 next_event = tevent_timeval_current_ofs(10, 0);
574 /* TODO: check when the socket becomes readable, so that children
575 * are checked only when there is some activity ? */
576 te = tevent_add_timer(ev_ctx, spoolss_pool, next_event,
577 spoolssd_check_children, msg_ctx);
578 if (!te) {
579 DEBUG(2, ("Failed to set up children monitoring!\n"));
580 return false;
583 return true;
586 static void spoolssd_check_children(struct tevent_context *ev_ctx,
587 struct tevent_timer *te,
588 struct timeval current_time,
589 void *pvt)
591 struct messaging_context *msg_ctx;
593 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
595 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
597 spoolssd_schedule_check(ev_ctx, msg_ctx, current_time);
600 static void print_queue_forward(struct messaging_context *msg,
601 void *private_data,
602 uint32_t msg_type,
603 struct server_id server_id,
604 DATA_BLOB *data)
606 messaging_send_buf(msg, pid_to_procid(background_lpq_updater_pid),
607 MSG_PRINTER_UPDATE, data->data, data->length);
610 static char *get_bq_logfile(void)
612 char *lfile = lp_logfile(talloc_tos());
613 int rc;
615 if (lfile == NULL || lfile[0] == '\0') {
616 rc = asprintf(&lfile, "%s/log.%s.bq",
617 get_dyn_LOGFILEBASE(), DAEMON_NAME);
618 } else {
619 rc = asprintf(&lfile, "%s.bq", lp_logfile(talloc_tos()));
621 if (rc == -1) {
622 lfile = NULL;
624 return lfile;
627 pid_t start_spoolssd(struct tevent_context *ev_ctx,
628 struct messaging_context *msg_ctx)
630 struct rpc_srv_callbacks spoolss_cb;
631 struct dcerpc_binding_vector *v;
632 TALLOC_CTX *mem_ctx;
633 pid_t pid;
634 NTSTATUS status;
635 int listen_fd;
636 int ret;
637 bool ok;
639 DEBUG(1, ("Forking SPOOLSS Daemon\n"));
642 * Block signals before forking child as it will have to
643 * set its own handlers. Child will re-enable SIGHUP as
644 * soon as the handlers are set up.
646 BlockSignals(true, SIGTERM);
647 BlockSignals(true, SIGHUP);
649 pid = fork();
651 if (pid == -1) {
652 DEBUG(0, ("Failed to fork SPOOLSS [%s]\n",
653 strerror(errno)));
656 /* parent or error */
657 if (pid != 0) {
659 /* Re-enable SIGHUP before returnig */
660 BlockSignals(false, SIGTERM);
661 BlockSignals(false, SIGHUP);
662 return pid;
665 status = reinit_after_fork(msg_ctx,
666 ev_ctx,
667 true);
668 if (!NT_STATUS_IS_OK(status)) {
669 DEBUG(0,("reinit_after_fork() failed\n"));
670 smb_panic("reinit_after_fork() failed");
673 /* save the parent process id so the children can use it later */
674 parent_id = messaging_server_id(msg_ctx);
676 spoolss_reopen_logs(0);
677 pfh_daemon_config(DAEMON_NAME,
678 &pf_spoolss_cfg,
679 &default_pf_spoolss_cfg);
681 spoolss_setup_sig_term_handler(ev_ctx);
682 spoolss_setup_sig_hup_handler(ev_ctx, msg_ctx);
684 BlockSignals(false, SIGTERM);
685 BlockSignals(false, SIGHUP);
687 /* always start the backgroundqueue listner in spoolssd */
688 bq_logfile = get_bq_logfile();
689 pid = start_background_queue(ev_ctx, msg_ctx, bq_logfile);
690 if (pid > 0) {
691 background_lpq_updater_pid = pid;
694 /* the listening fd must be created before the children are actually
695 * forked out. */
696 listen_fd = create_named_pipe_socket(SPOOLSS_PIPE_NAME);
697 if (listen_fd == -1) {
698 exit(1);
701 ret = listen(listen_fd, pf_spoolss_cfg.max_allowed_clients);
702 if (ret == -1) {
703 DEBUG(0, ("Failed to listen on spoolss pipe - %s\n",
704 strerror(errno)));
705 exit(1);
708 /* start children before any more initialization is done */
709 ok = prefork_create_pool(ev_ctx, /* mem_ctx */
710 ev_ctx, msg_ctx,
711 1, &listen_fd,
712 pf_spoolss_cfg.min_children,
713 pf_spoolss_cfg.max_children,
714 &spoolss_children_main, NULL,
715 &spoolss_pool);
716 if (!ok) {
717 exit(1);
720 if (!serverid_register(messaging_server_id(msg_ctx),
721 FLAG_MSG_GENERAL |
722 FLAG_MSG_PRINT_GENERAL)) {
723 exit(1);
726 if (!locking_init()) {
727 exit(1);
730 messaging_register(msg_ctx, ev_ctx,
731 MSG_SMB_CONF_UPDATED, smb_conf_updated);
732 messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE,
733 print_queue_forward);
734 messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
735 pcap_updated);
736 messaging_register(msg_ctx, ev_ctx,
737 MSG_PREFORK_CHILD_EVENT, child_ping);
739 /* As soon as messaging is up check if pcap has been loaded already.
740 * If so then we probably missed a message and should load_printers()
741 * ourselves. If pcap has not been loaded yet, then ignore, we will get
742 * a message as soon as the bq process completes the reload. */
743 if (pcap_cache_loaded()) {
744 load_printers(ev_ctx, msg_ctx);
747 mem_ctx = talloc_new(NULL);
748 if (mem_ctx == NULL) {
749 exit(1);
753 * Initialize spoolss with an init function to convert printers first.
754 * static_init_rpc will try to initialize the spoolss server too but you
755 * can't register it twice.
757 spoolss_cb.init = spoolss_init_cb;
758 spoolss_cb.shutdown = spoolss_shutdown_cb;
759 spoolss_cb.private_data = msg_ctx;
761 status = rpc_winreg_init(NULL);
762 if (!NT_STATUS_IS_OK(status)) {
763 DEBUG(0, ("Failed to register winreg rpc inteface! (%s)\n",
764 nt_errstr(status)));
765 exit(1);
768 status = rpc_spoolss_init(&spoolss_cb);
769 if (!NT_STATUS_IS_OK(status)) {
770 DEBUG(0, ("Failed to register spoolss rpc inteface! (%s)\n",
771 nt_errstr(status)));
772 exit(1);
775 status = dcerpc_binding_vector_new(mem_ctx, &v);
776 if (!NT_STATUS_IS_OK(status)) {
777 DEBUG(0, ("Failed to create binding vector (%s)\n",
778 nt_errstr(status)));
779 exit(1);
782 status = dcerpc_binding_vector_add_np_default(&ndr_table_spoolss, v);
783 if (!NT_STATUS_IS_OK(status)) {
784 DEBUG(0, ("Failed to add np to binding vector (%s)\n",
785 nt_errstr(status)));
786 exit(1);
789 status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, v);
790 if (!NT_STATUS_IS_OK(status)) {
791 DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n",
792 nt_errstr(status)));
793 exit(1);
796 talloc_free(mem_ctx);
798 ok = spoolssd_setup_children_monitor(ev_ctx, msg_ctx);
799 if (!ok) {
800 DEBUG(0, ("Failed to setup children monitoring!\n"));
801 exit(1);
804 DEBUG(1, ("SPOOLSS Daemon Started (%d)\n", getpid()));
806 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
808 /* loop forever */
809 ret = tevent_loop_wait(ev_ctx);
811 /* should not be reached */
812 DEBUG(0,("spoolssd tevent_loop_wait() exited with %d - %s\n",
813 ret, (ret == 0) ? "out of events" : strerror(errno)));
814 exit(1);