s3:winbindd:idmap_autorid remove a stray comment
[Samba.git] / source3 / printing / spoolssd.c
blob48a914ef6de40280f2ff3b0c1953acbc4d0a8a7b
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/rpc_config.h"
35 #include "rpc_server/spoolss/srv_spoolss_nt.h"
36 #include "librpc/rpc/dcerpc_ep.h"
37 #include "lib/server_prefork.h"
38 #include "lib/server_prefork_util.h"
40 #define SPOOLSS_PIPE_NAME "spoolss"
41 #define DAEMON_NAME "spoolssd"
43 static struct server_id parent_id;
44 static struct prefork_pool *spoolss_pool = NULL;
45 static int spoolss_child_id = 0;
47 static struct pf_daemon_config default_pf_spoolss_cfg = {
48 .prefork_status = PFH_INIT,
49 .min_children = 5,
50 .max_children = 25,
51 .spawn_rate = 5,
52 .max_allowed_clients = 100,
53 .child_min_life = 60 /* 1 minute minimum life time */
55 static struct pf_daemon_config pf_spoolss_cfg = { 0 };
57 pid_t start_spoolssd(struct tevent_context *ev_ctx,
58 struct messaging_context *msg_ctx);
60 static void spoolss_reopen_logs(int child_id)
62 char *lfile = lp_logfile(talloc_tos());
63 char *ext;
64 int rc;
66 if (child_id) {
67 rc = asprintf(&ext, "%s.%d", DAEMON_NAME, child_id);
68 } else {
69 rc = asprintf(&ext, "%s", DAEMON_NAME);
72 if (rc == -1) {
73 return;
76 rc = 0;
77 if (lfile == NULL || lfile[0] == '\0') {
78 rc = asprintf(&lfile, "%s/log.%s",
79 get_dyn_LOGFILEBASE(), ext);
80 } else {
81 if (strstr(lfile, ext) == NULL) {
82 if (child_id) {
83 rc = asprintf(&lfile, "%s.%d",
84 lp_logfile(talloc_tos()),
85 child_id);
86 } else {
87 rc = asprintf(&lfile, "%s.%s",
88 lp_logfile(talloc_tos()),
89 ext);
94 if (rc > 0) {
95 lp_set_logfile(lfile);
96 SAFE_FREE(lfile);
99 SAFE_FREE(ext);
101 reopen_logs();
104 static void update_conf(struct tevent_context *ev,
105 struct messaging_context *msg)
107 change_to_root_user();
108 lp_load_global(get_dyn_CONFIGFILE());
109 load_printers(ev, msg);
111 spoolss_reopen_logs(spoolss_child_id);
112 if (spoolss_child_id == 0) {
113 pfh_daemon_config(DAEMON_NAME,
114 &pf_spoolss_cfg,
115 &default_pf_spoolss_cfg);
116 pfh_manage_pool(ev, msg, &pf_spoolss_cfg, spoolss_pool);
120 static void smb_conf_updated(struct messaging_context *msg,
121 void *private_data,
122 uint32_t msg_type,
123 struct server_id server_id,
124 DATA_BLOB *data)
126 struct tevent_context *ev_ctx = talloc_get_type_abort(private_data,
127 struct tevent_context);
129 DEBUG(10, ("Got message saying smb.conf was updated. Reloading.\n"));
130 update_conf(ev_ctx, msg);
133 static void spoolss_sig_term_handler(struct tevent_context *ev,
134 struct tevent_signal *se,
135 int signum,
136 int count,
137 void *siginfo,
138 void *private_data)
140 exit_server_cleanly("termination signal");
143 static void spoolss_setup_sig_term_handler(struct tevent_context *ev_ctx)
145 struct tevent_signal *se;
147 se = tevent_add_signal(ev_ctx,
148 ev_ctx,
149 SIGTERM, 0,
150 spoolss_sig_term_handler,
151 NULL);
152 if (!se) {
153 exit_server("failed to setup SIGTERM handler");
157 static void spoolss_sig_hup_handler(struct tevent_context *ev,
158 struct tevent_signal *se,
159 int signum,
160 int count,
161 void *siginfo,
162 void *pvt)
164 struct messaging_context *msg_ctx;
166 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
168 DEBUG(1,("Reloading printers after SIGHUP\n"));
169 update_conf(ev, msg_ctx);
171 /* relay to all children */
172 if (spoolss_pool) {
173 prefork_send_signal_to_all(spoolss_pool, SIGHUP);
177 static void spoolss_setup_sig_hup_handler(struct tevent_context *ev_ctx,
178 struct messaging_context *msg_ctx)
180 struct tevent_signal *se;
182 se = tevent_add_signal(ev_ctx,
183 ev_ctx,
184 SIGHUP, 0,
185 spoolss_sig_hup_handler,
186 msg_ctx);
187 if (!se) {
188 exit_server("failed to setup SIGHUP handler");
192 static bool spoolss_init_cb(void *ptr)
194 struct messaging_context *msg_ctx = talloc_get_type_abort(
195 ptr, struct messaging_context);
197 return nt_printing_tdb_migrate(msg_ctx);
200 static bool spoolss_shutdown_cb(void *ptr)
202 srv_spoolss_cleanup();
204 return true;
207 /* Children */
209 static void spoolss_chld_sig_hup_handler(struct tevent_context *ev,
210 struct tevent_signal *se,
211 int signum,
212 int count,
213 void *siginfo,
214 void *pvt)
216 struct messaging_context *msg_ctx;
218 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
220 change_to_root_user();
221 DEBUG(1,("Reloading printers after SIGHUP\n"));
222 load_printers(ev, msg_ctx);
223 spoolss_reopen_logs(spoolss_child_id);
226 static bool spoolss_setup_chld_hup_handler(struct tevent_context *ev_ctx,
227 struct messaging_context *msg_ctx,
228 struct pf_worker_data *pf)
230 struct tevent_signal *se;
232 se = tevent_add_signal(ev_ctx,
233 ev_ctx,
234 SIGHUP, 0,
235 spoolss_chld_sig_hup_handler,
236 msg_ctx);
237 if (!se) {
238 DEBUG(1, ("failed to setup SIGHUP handler"));
239 return false;
242 return true;
245 static void parent_ping(struct messaging_context *msg_ctx,
246 void *private_data,
247 uint32_t msg_type,
248 struct server_id server_id,
249 DATA_BLOB *data)
252 /* The fact we received this message is enough to let make the event
253 * loop if it was idle. spoolss_children_main will cycle through
254 * spoolss_next_client at least once. That function will take whatever
255 * action is necessary */
257 DEBUG(10, ("Got message that the parent changed status.\n"));
258 return;
261 static bool spoolss_child_init(struct tevent_context *ev_ctx,
262 int child_id, struct pf_worker_data *pf)
264 NTSTATUS status;
265 struct rpc_srv_callbacks spoolss_cb;
266 struct messaging_context *msg_ctx = server_messaging_context();
267 bool ok;
269 status = reinit_after_fork(msg_ctx, ev_ctx, true, "spoolssd-child");
270 if (!NT_STATUS_IS_OK(status)) {
271 DEBUG(0,("reinit_after_fork() failed\n"));
272 smb_panic("reinit_after_fork() failed");
275 spoolss_child_id = child_id;
276 spoolss_reopen_logs(child_id);
278 ok = spoolss_setup_chld_hup_handler(ev_ctx, msg_ctx, pf);
279 if (!ok) {
280 return false;
283 if (!serverid_register(messaging_server_id(msg_ctx),
284 FLAG_MSG_GENERAL |
285 FLAG_MSG_PRINT_GENERAL)) {
286 return false;
289 if (!locking_init()) {
290 return false;
293 messaging_register(msg_ctx, ev_ctx,
294 MSG_SMB_CONF_UPDATED, smb_conf_updated);
295 messaging_register(msg_ctx, ev_ctx,
296 MSG_PREFORK_PARENT_EVENT, parent_ping);
298 /* As soon as messaging is up check if pcap has been loaded already.
299 * If so then we probably missed a message and should load_printers()
300 * ourselves. If pcap has not been loaded yet, then ignore, we will get
301 * a message as soon as the bq process completes the reload. */
302 if (pcap_cache_loaded(NULL)) {
303 load_printers(ev_ctx, msg_ctx);
306 /* try to reinit rpc queues */
307 spoolss_cb.init = spoolss_init_cb;
308 spoolss_cb.shutdown = spoolss_shutdown_cb;
309 spoolss_cb.private_data = msg_ctx;
311 status = rpc_winreg_init(NULL);
312 if (!NT_STATUS_IS_OK(status)) {
313 DEBUG(0, ("Failed to register winreg rpc interface! (%s)\n",
314 nt_errstr(status)));
315 return false;
318 status = rpc_spoolss_init(&spoolss_cb);
319 if (!NT_STATUS_IS_OK(status)) {
320 DEBUG(0, ("Failed to register spoolss rpc interface! (%s)\n",
321 nt_errstr(status)));
322 return false;
325 return true;
328 struct spoolss_children_data {
329 struct tevent_context *ev_ctx;
330 struct messaging_context *msg_ctx;
331 struct pf_worker_data *pf;
332 int listen_fd_size;
333 int *listen_fds;
336 static void spoolss_next_client(void *pvt);
338 static int spoolss_children_main(struct tevent_context *ev_ctx,
339 struct messaging_context *msg_ctx,
340 struct pf_worker_data *pf,
341 int child_id,
342 int listen_fd_size,
343 int *listen_fds,
344 void *private_data)
346 struct spoolss_children_data *data;
347 bool ok;
348 int ret = 0;
350 ok = spoolss_child_init(ev_ctx, child_id, pf);
351 if (!ok) {
352 return 1;
355 data = talloc(ev_ctx, struct spoolss_children_data);
356 if (!data) {
357 return 1;
359 data->pf = pf;
360 data->ev_ctx = ev_ctx;
361 data->msg_ctx = msg_ctx;
362 data->listen_fd_size = listen_fd_size;
363 data->listen_fds = listen_fds;
365 /* loop until it is time to exit */
366 while (pf->status != PF_WORKER_EXITING) {
367 /* try to see if it is time to schedule the next client */
368 spoolss_next_client(data);
370 ret = tevent_loop_once(ev_ctx);
371 if (ret != 0) {
372 DEBUG(0, ("tevent_loop_once() exited with %d: %s\n",
373 ret, strerror(errno)));
374 pf->status = PF_WORKER_EXITING;
378 return ret;
381 static void spoolss_client_terminated(void *pvt)
383 struct spoolss_children_data *data;
385 data = talloc_get_type_abort(pvt, struct spoolss_children_data);
387 pfh_client_terminated(data->pf);
389 spoolss_next_client(pvt);
392 struct spoolss_new_client {
393 struct spoolss_children_data *data;
394 struct tsocket_address *srv_addr;
395 struct tsocket_address *cli_addr;
398 static void spoolss_handle_client(struct tevent_req *req);
400 static void spoolss_next_client(void *pvt)
402 struct tevent_req *req;
403 struct spoolss_children_data *data;
404 struct spoolss_new_client *next;
406 data = talloc_get_type_abort(pvt, struct spoolss_children_data);
408 if (!pfh_child_allowed_to_accept(data->pf)) {
409 /* nothing to do for now we are already listening
410 * or we are not allowed to listen further */
411 return;
414 next = talloc_zero(data, struct spoolss_new_client);
415 if (!next) {
416 DEBUG(1, ("Out of memory!?\n"));
417 return;
419 next->data = data;
421 req = prefork_listen_send(next, data->ev_ctx, data->pf,
422 data->listen_fd_size,
423 data->listen_fds);
424 if (!req) {
425 DEBUG(1, ("Failed to make listening request!?\n"));
426 talloc_free(next);
427 return;
429 tevent_req_set_callback(req, spoolss_handle_client, next);
432 static void spoolss_handle_client(struct tevent_req *req)
434 struct spoolss_children_data *data;
435 struct spoolss_new_client *client;
436 const DATA_BLOB ping = data_blob_null;
437 int ret;
438 int sd;
440 client = tevent_req_callback_data(req, struct spoolss_new_client);
441 data = client->data;
443 ret = prefork_listen_recv(req, client, &sd,
444 &client->srv_addr, &client->cli_addr);
446 /* this will free the request too */
447 talloc_free(client);
449 if (ret != 0) {
450 DEBUG(6, ("No client connection was available after all!\n"));
451 return;
454 /* Warn parent that our status changed */
455 messaging_send(data->msg_ctx, parent_id,
456 MSG_PREFORK_CHILD_EVENT, &ping);
458 DEBUG(2, ("Spoolss preforked child %d got client connection!\n",
459 (int)(data->pf->pid)));
461 named_pipe_accept_function(data->ev_ctx, data->msg_ctx,
462 SPOOLSS_PIPE_NAME, sd,
463 spoolss_client_terminated, data);
466 /* ==== Main Process Functions ==== */
468 extern pid_t background_lpq_updater_pid;
469 static char *bq_logfile;
471 static void check_updater_child(struct tevent_context *ev_ctx,
472 struct messaging_context *msg_ctx)
474 int status;
475 pid_t pid;
477 if (background_lpq_updater_pid == -1) {
478 return;
481 pid = waitpid(background_lpq_updater_pid, &status, WNOHANG);
482 if (pid > 0) {
483 DEBUG(2, ("The background queue child died... Restarting!\n"));
484 pid = start_background_queue(ev_ctx, msg_ctx, bq_logfile);
485 background_lpq_updater_pid = pid;
489 static void child_ping(struct messaging_context *msg_ctx,
490 void *private_data,
491 uint32_t msg_type,
492 struct server_id server_id,
493 DATA_BLOB *data)
495 struct tevent_context *ev_ctx;
497 ev_ctx = talloc_get_type_abort(private_data, struct tevent_context);
499 DEBUG(10, ("Got message that a child changed status.\n"));
500 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
503 static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
504 struct messaging_context *msg_ctx,
505 struct timeval current_time);
506 static void spoolssd_check_children(struct tevent_context *ev_ctx,
507 struct tevent_timer *te,
508 struct timeval current_time,
509 void *pvt);
511 static void spoolssd_sigchld_handler(struct tevent_context *ev_ctx,
512 struct prefork_pool *pfp,
513 void *pvt)
515 struct messaging_context *msg_ctx;
517 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
519 /* run pool management so we can fork/retire or increase
520 * the allowed connections per child based on load */
521 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
523 /* also check if the updater child is alive and well */
524 check_updater_child(ev_ctx, msg_ctx);
527 static bool spoolssd_setup_children_monitor(struct tevent_context *ev_ctx,
528 struct messaging_context *msg_ctx)
530 bool ok;
532 /* add our oun sigchld callback */
533 prefork_set_sigchld_callback(spoolss_pool,
534 spoolssd_sigchld_handler, msg_ctx);
536 ok = spoolssd_schedule_check(ev_ctx, msg_ctx,
537 tevent_timeval_current());
538 return ok;
541 static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
542 struct messaging_context *msg_ctx,
543 struct timeval current_time)
545 struct tevent_timer *te;
546 struct timeval next_event;
548 /* check situation again in 10 seconds */
549 next_event = tevent_timeval_current_ofs(10, 0);
551 /* TODO: check when the socket becomes readable, so that children
552 * are checked only when there is some activity ? */
553 te = tevent_add_timer(ev_ctx, spoolss_pool, next_event,
554 spoolssd_check_children, msg_ctx);
555 if (!te) {
556 DEBUG(2, ("Failed to set up children monitoring!\n"));
557 return false;
560 return true;
563 static void spoolssd_check_children(struct tevent_context *ev_ctx,
564 struct tevent_timer *te,
565 struct timeval current_time,
566 void *pvt)
568 struct messaging_context *msg_ctx;
570 msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
572 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
574 spoolssd_schedule_check(ev_ctx, msg_ctx, current_time);
577 static void print_queue_forward(struct messaging_context *msg,
578 void *private_data,
579 uint32_t msg_type,
580 struct server_id server_id,
581 DATA_BLOB *data)
583 messaging_send_buf(msg, pid_to_procid(background_lpq_updater_pid),
584 MSG_PRINTER_UPDATE, data->data, data->length);
587 static char *get_bq_logfile(void)
589 char *lfile = lp_logfile(talloc_tos());
590 int rc;
592 if (lfile == NULL || lfile[0] == '\0') {
593 rc = asprintf(&lfile, "%s/log.%s.bq",
594 get_dyn_LOGFILEBASE(), DAEMON_NAME);
595 } else {
596 rc = asprintf(&lfile, "%s.bq", lp_logfile(talloc_tos()));
598 if (rc == -1) {
599 lfile = NULL;
601 return lfile;
604 pid_t start_spoolssd(struct tevent_context *ev_ctx,
605 struct messaging_context *msg_ctx)
607 enum rpc_service_mode_e epm_mode = rpc_epmapper_mode();
608 struct rpc_srv_callbacks spoolss_cb;
609 struct dcerpc_binding_vector *v;
610 TALLOC_CTX *mem_ctx;
611 pid_t pid;
612 NTSTATUS status;
613 int listen_fd;
614 int ret;
615 bool ok;
617 DEBUG(1, ("Forking SPOOLSS Daemon\n"));
620 * Block signals before forking child as it will have to
621 * set its own handlers. Child will re-enable SIGHUP as
622 * soon as the handlers are set up.
624 BlockSignals(true, SIGTERM);
625 BlockSignals(true, SIGHUP);
627 pid = fork();
629 if (pid == -1) {
630 DEBUG(0, ("Failed to fork SPOOLSS [%s]\n",
631 strerror(errno)));
634 /* parent or error */
635 if (pid != 0) {
637 /* Re-enable SIGHUP before returnig */
638 BlockSignals(false, SIGTERM);
639 BlockSignals(false, SIGHUP);
640 return pid;
643 status = smbd_reinit_after_fork(msg_ctx, ev_ctx, true,
644 "spoolssd-master");
645 if (!NT_STATUS_IS_OK(status)) {
646 DEBUG(0,("reinit_after_fork() failed\n"));
647 smb_panic("reinit_after_fork() failed");
650 /* save the parent process id so the children can use it later */
651 parent_id = messaging_server_id(msg_ctx);
653 spoolss_reopen_logs(0);
654 pfh_daemon_config(DAEMON_NAME,
655 &pf_spoolss_cfg,
656 &default_pf_spoolss_cfg);
658 spoolss_setup_sig_term_handler(ev_ctx);
659 spoolss_setup_sig_hup_handler(ev_ctx, msg_ctx);
661 BlockSignals(false, SIGTERM);
662 BlockSignals(false, SIGHUP);
664 /* always start the backgroundqueue listner in spoolssd */
665 bq_logfile = get_bq_logfile();
666 pid = start_background_queue(ev_ctx, msg_ctx, bq_logfile);
667 if (pid > 0) {
668 background_lpq_updater_pid = pid;
671 /* the listening fd must be created before the children are actually
672 * forked out. */
673 listen_fd = create_named_pipe_socket(SPOOLSS_PIPE_NAME);
674 if (listen_fd == -1) {
675 exit(1);
678 ret = listen(listen_fd, pf_spoolss_cfg.max_allowed_clients);
679 if (ret == -1) {
680 DEBUG(0, ("Failed to listen on spoolss pipe - %s\n",
681 strerror(errno)));
682 exit(1);
685 /* start children before any more initialization is done */
686 ok = prefork_create_pool(ev_ctx, /* mem_ctx */
687 ev_ctx, msg_ctx,
688 1, &listen_fd,
689 pf_spoolss_cfg.min_children,
690 pf_spoolss_cfg.max_children,
691 &spoolss_children_main, NULL,
692 &spoolss_pool);
693 if (!ok) {
694 exit(1);
697 if (!serverid_register(messaging_server_id(msg_ctx),
698 FLAG_MSG_GENERAL |
699 FLAG_MSG_PRINT_GENERAL)) {
700 exit(1);
703 if (!locking_init()) {
704 exit(1);
707 messaging_register(msg_ctx, ev_ctx,
708 MSG_SMB_CONF_UPDATED, smb_conf_updated);
709 messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE,
710 print_queue_forward);
711 messaging_register(msg_ctx, ev_ctx,
712 MSG_PREFORK_CHILD_EVENT, child_ping);
715 * As soon as messaging is up check if pcap has been loaded already.
716 * If pcap has not been loaded yet, then ignore, as we will reload on
717 * client enumeration anyway.
719 if (pcap_cache_loaded(NULL)) {
720 load_printers(ev_ctx, msg_ctx);
723 mem_ctx = talloc_new(NULL);
724 if (mem_ctx == NULL) {
725 exit(1);
729 * Initialize spoolss with an init function to convert printers first.
730 * static_init_rpc will try to initialize the spoolss server too but you
731 * can't register it twice.
733 spoolss_cb.init = spoolss_init_cb;
734 spoolss_cb.shutdown = spoolss_shutdown_cb;
735 spoolss_cb.private_data = msg_ctx;
737 status = rpc_winreg_init(NULL);
738 if (!NT_STATUS_IS_OK(status)) {
739 DEBUG(0, ("Failed to register winreg rpc interface! (%s)\n",
740 nt_errstr(status)));
741 exit(1);
744 status = rpc_spoolss_init(&spoolss_cb);
745 if (!NT_STATUS_IS_OK(status)) {
746 DEBUG(0, ("Failed to register spoolss rpc interface! (%s)\n",
747 nt_errstr(status)));
748 exit(1);
751 if (epm_mode != RPC_SERVICE_MODE_DISABLED &&
752 (lp_parm_bool(-1, "rpc_server", "register_embedded_np", false))) {
753 status = dcerpc_binding_vector_new(mem_ctx, &v);
754 if (!NT_STATUS_IS_OK(status)) {
755 DEBUG(0, ("Failed to create binding vector (%s)\n",
756 nt_errstr(status)));
757 exit(1);
760 status = dcerpc_binding_vector_add_np_default(&ndr_table_spoolss, v);
761 if (!NT_STATUS_IS_OK(status)) {
762 DEBUG(0, ("Failed to add np to binding vector (%s)\n",
763 nt_errstr(status)));
764 exit(1);
767 status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, v);
768 if (!NT_STATUS_IS_OK(status)) {
769 DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n",
770 nt_errstr(status)));
771 exit(1);
775 talloc_free(mem_ctx);
777 ok = spoolssd_setup_children_monitor(ev_ctx, msg_ctx);
778 if (!ok) {
779 DEBUG(0, ("Failed to setup children monitoring!\n"));
780 exit(1);
783 DEBUG(1, ("SPOOLSS Daemon Started (%u)\n", (unsigned int)getpid()));
785 pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
787 /* loop forever */
788 ret = tevent_loop_wait(ev_ctx);
790 /* should not be reached */
791 DEBUG(0,("spoolssd tevent_loop_wait() exited with %d - %s\n",
792 ret, (ret == 0) ? "out of events" : strerror(errno)));
793 exit(1);