2 Unix SMB/CIFS implementation.
4 Winbind daemon for ntdom nss module
6 Copyright (C) by Tim Potter 2000-2002
7 Copyright (C) Andrew Tridgell 2002
8 Copyright (C) Jelmer Vernooij 2003
9 Copyright (C) Volker Lendecke 2004
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "popt_common.h"
28 #include "nsswitch/winbind_client.h"
29 #include "nsswitch/wb_reqtrans.h"
31 #include "../librpc/gen_ndr/srv_lsa.h"
32 #include "../librpc/gen_ndr/srv_samr.h"
34 #include "rpc_client/cli_netlogon.h"
36 #include "lib/addrchange.h"
40 #include "../lib/util/pidfile.h"
41 #include "util_cluster.h"
42 #include "source4/lib/messaging/irpc.h"
43 #include "source4/lib/messaging/messaging.h"
44 #include "lib/param/param.h"
45 #include "lib/async_req/async_sock.h"
48 #define DBGC_CLASS DBGC_WINBIND
50 #define SCRUB_CLIENTS_INTERVAL 5
52 static bool client_is_idle(struct winbindd_cli_state *state);
53 static void remove_client(struct winbindd_cli_state *state);
54 static void winbindd_setup_max_fds(void);
56 static bool opt_nocache = False;
57 static bool interactive = False;
59 extern bool override_logfile;
61 struct tevent_context *winbind_event_context(void)
63 static struct tevent_context *ev = NULL;
70 * Note we MUST use the NULL context here, not the autofree context,
71 * to avoid side effects in forked children exiting.
73 ev = samba_tevent_context_init(NULL);
75 smb_panic("Could not init winbindd's messaging context.\n");
80 struct messaging_context *winbind_messaging_context(void)
82 static struct messaging_context *msg = NULL;
89 * Note we MUST use the NULL context here, not the autofree context,
90 * to avoid side effects in forked children exiting.
92 msg = messaging_init(NULL, winbind_event_context());
94 smb_panic("Could not init winbindd's messaging context.\n");
99 struct imessaging_context *winbind_imessaging_context(void)
101 static struct imessaging_context *msg = NULL;
102 struct messaging_context *msg_ctx;
103 struct server_id myself;
104 struct loadparm_context *lp_ctx;
110 msg_ctx = server_messaging_context();
111 if (msg_ctx == NULL) {
112 smb_panic("server_messaging_context failed\n");
114 myself = messaging_server_id(msg_ctx);
116 lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers());
117 if (lp_ctx == NULL) {
118 smb_panic("Could not load smb.conf to init winbindd's imessaging context.\n");
122 * Note we MUST use the NULL context here, not the autofree context,
123 * to avoid side effects in forked children exiting.
125 msg = imessaging_init(NULL, lp_ctx, myself, winbind_event_context(),
127 talloc_unlink(NULL, lp_ctx);
130 smb_panic("Could not init winbindd's messaging context.\n");
135 /* Reload configuration */
137 static bool reload_services_file(const char *lfile)
142 char *fname = lp_next_configfile(talloc_tos());
144 if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
145 set_dyn_CONFIGFILE(fname);
150 /* if this is a child, restore the logfile to the special
151 name - <domain>, idmap, etc. */
152 if (lfile && *lfile) {
153 lp_set_logfile(lfile);
157 ret = lp_load_global(get_dyn_CONFIGFILE());
161 winbindd_setup_max_fds();
167 static void winbindd_status(void)
169 struct winbindd_cli_state *tmp;
171 DEBUG(0, ("winbindd status:\n"));
173 /* Print client state information */
175 DEBUG(0, ("\t%d clients currently active\n", winbindd_num_clients()));
177 if (DEBUGLEVEL >= 2 && winbindd_num_clients()) {
178 DEBUG(2, ("\tclient list:\n"));
179 for(tmp = winbindd_client_list(); tmp; tmp = tmp->next) {
180 DEBUGADD(2, ("\t\tpid %lu, sock %d (%s)\n",
181 (unsigned long)tmp->pid, tmp->sock,
182 client_is_idle(tmp) ? "idle" : "active"));
187 /* Flush client cache */
189 static void flush_caches(void)
191 /* We need to invalidate cached user list entries on a SIGHUP
192 otherwise cached access denied errors due to restrict anonymous
193 hang around until the sequence number changes. */
195 if (!wcache_invalidate_cache()) {
196 DEBUG(0, ("invalidating the cache failed; revalidate the cache\n"));
197 if (!winbindd_cache_validate_and_initialize()) {
203 static void flush_caches_noinit(void)
206 * We need to invalidate cached user list entries on a SIGHUP
207 * otherwise cached access denied errors due to restrict anonymous
208 * hang around until the sequence number changes.
210 * Skip uninitialized domains when flush cache.
211 * If domain is not initialized, it means it is never
212 * used or never become online. look, wcache_invalidate_cache()
213 * -> get_cache() -> init_dc_connection(). It causes a lot of traffic
214 * for unused domains and large traffic for primay domain's DC if there
218 if (!wcache_invalidate_cache_noinit()) {
219 DEBUG(0, ("invalidating the cache failed; revalidate the cache\n"));
220 if (!winbindd_cache_validate_and_initialize()) {
226 /* Handle the signal by unlinking socket and exiting */
228 static void terminate(bool is_parent)
231 /* When parent goes away we should
232 * remove the socket file. Not so
233 * when children terminate.
237 if (asprintf(&path, "%s/%s",
238 lp_winbindd_socket_directory(), WINBINDD_SOCKET_NAME) > 0) {
246 trustdom_cache_shutdown();
248 gencache_stabilize();
252 TALLOC_CTX *mem_ctx = talloc_init("end_description");
253 char *description = talloc_describe_all(mem_ctx);
255 DEBUG(3, ("tallocs left:\n%s\n", description));
256 talloc_destroy(mem_ctx);
261 struct messaging_context *msg = winbind_messaging_context();
262 struct server_id self = messaging_server_id(msg);
263 serverid_deregister(self);
264 pidfile_unlink(lp_pid_directory(), "winbindd");
270 static void winbindd_sig_term_handler(struct tevent_context *ev,
271 struct tevent_signal *se,
277 bool *is_parent = talloc_get_type_abort(private_data, bool);
279 DEBUG(0,("Got sig[%d] terminate (is_parent=%d)\n",
280 signum, (int)*is_parent));
281 terminate(*is_parent);
285 handle stdin becoming readable when we are in --foreground mode
287 static void winbindd_stdin_handler(struct tevent_context *ev,
288 struct tevent_fd *fde,
293 if (read(0, &c, 1) != 1) {
294 bool *is_parent = talloc_get_type_abort(private_data, bool);
296 /* we have reached EOF on stdin, which means the
297 parent has exited. Shutdown the server */
298 DEBUG(0,("EOF on stdin (is_parent=%d)\n",
300 terminate(*is_parent);
304 bool winbindd_setup_sig_term_handler(bool parent)
306 struct tevent_signal *se;
309 is_parent = talloc(winbind_event_context(), bool);
316 se = tevent_add_signal(winbind_event_context(),
319 winbindd_sig_term_handler,
322 DEBUG(0,("failed to setup SIGTERM handler"));
323 talloc_free(is_parent);
327 se = tevent_add_signal(winbind_event_context(),
330 winbindd_sig_term_handler,
333 DEBUG(0,("failed to setup SIGINT handler"));
334 talloc_free(is_parent);
338 se = tevent_add_signal(winbind_event_context(),
341 winbindd_sig_term_handler,
344 DEBUG(0,("failed to setup SIGINT handler"));
345 talloc_free(is_parent);
352 bool winbindd_setup_stdin_handler(bool parent, bool foreground)
359 is_parent = talloc(winbind_event_context(), bool);
366 /* if we are running in the foreground then look for
367 EOF on stdin, and exit if it happens. This allows
368 us to die if the parent process dies
369 Only do this on a pipe or socket, no other device.
371 if (fstat(0, &st) != 0) {
374 if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
375 tevent_add_fd(winbind_event_context(),
379 winbindd_stdin_handler,
387 static void winbindd_sig_hup_handler(struct tevent_context *ev,
388 struct tevent_signal *se,
394 const char *file = (const char *)private_data;
396 DEBUG(1,("Reloading services after SIGHUP\n"));
397 flush_caches_noinit();
398 reload_services_file(file);
401 bool winbindd_setup_sig_hup_handler(const char *lfile)
403 struct tevent_signal *se;
407 file = talloc_strdup(winbind_event_context(),
414 se = tevent_add_signal(winbind_event_context(),
415 winbind_event_context(),
417 winbindd_sig_hup_handler,
426 static void winbindd_sig_chld_handler(struct tevent_context *ev,
427 struct tevent_signal *se,
435 while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) {
436 winbind_child_died(pid);
440 static bool winbindd_setup_sig_chld_handler(void)
442 struct tevent_signal *se;
444 se = tevent_add_signal(winbind_event_context(),
445 winbind_event_context(),
447 winbindd_sig_chld_handler,
456 static void winbindd_sig_usr2_handler(struct tevent_context *ev,
457 struct tevent_signal *se,
466 static bool winbindd_setup_sig_usr2_handler(void)
468 struct tevent_signal *se;
470 se = tevent_add_signal(winbind_event_context(),
471 winbind_event_context(),
473 winbindd_sig_usr2_handler,
482 /* React on 'smbcontrol winbindd reload-config' in the same way as on SIGHUP*/
483 static void msg_reload_services(struct messaging_context *msg,
486 struct server_id server_id,
489 /* Flush various caches */
491 reload_services_file((const char *) private_data);
494 /* React on 'smbcontrol winbindd shutdown' in the same way as on SIGTERM*/
495 static void msg_shutdown(struct messaging_context *msg,
498 struct server_id server_id,
501 /* only the parent waits for this message */
502 DEBUG(0,("Got shutdown message\n"));
507 static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
510 struct server_id server_id,
517 DEBUG(10, ("winbindd_msg_validate_cache: got validate-cache "
521 * call the validation code from a child:
522 * so we don't block the main winbindd and the validation
523 * code can safely use fork/waitpid...
527 if (child_pid == -1) {
528 DEBUG(1, ("winbind_msg_validate_cache: Could not fork: %s\n",
533 if (child_pid != 0) {
535 DEBUG(5, ("winbind_msg_validate_cache: child created with "
536 "pid %d.\n", (int)child_pid));
542 status = winbindd_reinit_after_fork(NULL, NULL);
543 if (!NT_STATUS_IS_OK(status)) {
544 DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
549 /* install default SIGCHLD handler: validation code uses fork/waitpid */
550 CatchSignal(SIGCHLD, SIG_DFL);
552 ret = (uint8_t)winbindd_validate_cache_nobackup();
553 DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret));
554 messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_VALIDATE_CACHE, &ret,
559 static struct winbindd_dispatch_table {
560 enum winbindd_cmd cmd;
561 void (*fn)(struct winbindd_cli_state *state);
562 const char *winbindd_cmd_name;
563 } dispatch_table[] = {
565 /* Enumeration functions */
567 { WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains,
572 { WINBINDD_INFO, winbindd_info, "INFO" },
573 { WINBINDD_INTERFACE_VERSION, winbindd_interface_version,
574 "INTERFACE_VERSION" },
575 { WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" },
576 { WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
577 { WINBINDD_DC_INFO, winbindd_dc_info, "DC_INFO" },
578 { WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" },
579 { WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
580 "WINBINDD_PRIV_PIPE_DIR" },
582 /* Credential cache access */
583 { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },
584 { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" },
588 { WINBINDD_NUM_CMDS, NULL, "NONE" }
591 struct winbindd_async_dispatch_table {
592 enum winbindd_cmd cmd;
593 const char *cmd_name;
594 struct tevent_req *(*send_req)(TALLOC_CTX *mem_ctx,
595 struct tevent_context *ev,
596 struct winbindd_cli_state *cli,
597 struct winbindd_request *request);
598 NTSTATUS (*recv_req)(struct tevent_req *req,
599 struct winbindd_response *presp);
602 static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
603 { WINBINDD_PING, "PING",
604 wb_ping_send, wb_ping_recv },
605 { WINBINDD_LOOKUPSID, "LOOKUPSID",
606 winbindd_lookupsid_send, winbindd_lookupsid_recv },
607 { WINBINDD_LOOKUPSIDS, "LOOKUPSIDS",
608 winbindd_lookupsids_send, winbindd_lookupsids_recv },
609 { WINBINDD_LOOKUPNAME, "LOOKUPNAME",
610 winbindd_lookupname_send, winbindd_lookupname_recv },
611 { WINBINDD_SID_TO_GID, "SID_TO_GID",
612 winbindd_sid_to_gid_send, winbindd_sid_to_gid_recv },
613 { WINBINDD_UID_TO_SID, "UID_TO_SID",
614 winbindd_uid_to_sid_send, winbindd_uid_to_sid_recv },
615 { WINBINDD_GID_TO_SID, "GID_TO_SID",
616 winbindd_gid_to_sid_send, winbindd_gid_to_sid_recv },
617 { WINBINDD_SIDS_TO_XIDS, "SIDS_TO_XIDS",
618 winbindd_sids_to_xids_send, winbindd_sids_to_xids_recv },
619 { WINBINDD_XIDS_TO_SIDS, "XIDS_TO_SIDS",
620 winbindd_xids_to_sids_send, winbindd_xids_to_sids_recv },
621 { WINBINDD_GETPWSID, "GETPWSID",
622 winbindd_getpwsid_send, winbindd_getpwsid_recv },
623 { WINBINDD_GETPWNAM, "GETPWNAM",
624 winbindd_getpwnam_send, winbindd_getpwnam_recv },
625 { WINBINDD_GETPWUID, "GETPWUID",
626 winbindd_getpwuid_send, winbindd_getpwuid_recv },
627 { WINBINDD_GETSIDALIASES, "GETSIDALIASES",
628 winbindd_getsidaliases_send, winbindd_getsidaliases_recv },
629 { WINBINDD_GETUSERDOMGROUPS, "GETUSERDOMGROUPS",
630 winbindd_getuserdomgroups_send, winbindd_getuserdomgroups_recv },
631 { WINBINDD_GETGROUPS, "GETGROUPS",
632 winbindd_getgroups_send, winbindd_getgroups_recv },
633 { WINBINDD_SHOW_SEQUENCE, "SHOW_SEQUENCE",
634 winbindd_show_sequence_send, winbindd_show_sequence_recv },
635 { WINBINDD_GETGRGID, "GETGRGID",
636 winbindd_getgrgid_send, winbindd_getgrgid_recv },
637 { WINBINDD_GETGRNAM, "GETGRNAM",
638 winbindd_getgrnam_send, winbindd_getgrnam_recv },
639 { WINBINDD_GETUSERSIDS, "GETUSERSIDS",
640 winbindd_getusersids_send, winbindd_getusersids_recv },
641 { WINBINDD_LOOKUPRIDS, "LOOKUPRIDS",
642 winbindd_lookuprids_send, winbindd_lookuprids_recv },
643 { WINBINDD_SETPWENT, "SETPWENT",
644 winbindd_setpwent_send, winbindd_setpwent_recv },
645 { WINBINDD_GETPWENT, "GETPWENT",
646 winbindd_getpwent_send, winbindd_getpwent_recv },
647 { WINBINDD_ENDPWENT, "ENDPWENT",
648 winbindd_endpwent_send, winbindd_endpwent_recv },
649 { WINBINDD_DSGETDCNAME, "DSGETDCNAME",
650 winbindd_dsgetdcname_send, winbindd_dsgetdcname_recv },
651 { WINBINDD_GETDCNAME, "GETDCNAME",
652 winbindd_getdcname_send, winbindd_getdcname_recv },
653 { WINBINDD_SETGRENT, "SETGRENT",
654 winbindd_setgrent_send, winbindd_setgrent_recv },
655 { WINBINDD_GETGRENT, "GETGRENT",
656 winbindd_getgrent_send, winbindd_getgrent_recv },
657 { WINBINDD_ENDGRENT, "ENDGRENT",
658 winbindd_endgrent_send, winbindd_endgrent_recv },
659 { WINBINDD_LIST_USERS, "LIST_USERS",
660 winbindd_list_users_send, winbindd_list_users_recv },
661 { WINBINDD_LIST_GROUPS, "LIST_GROUPS",
662 winbindd_list_groups_send, winbindd_list_groups_recv },
663 { WINBINDD_CHECK_MACHACC, "CHECK_MACHACC",
664 winbindd_check_machine_acct_send, winbindd_check_machine_acct_recv },
665 { WINBINDD_PING_DC, "PING_DC",
666 winbindd_ping_dc_send, winbindd_ping_dc_recv },
667 { WINBINDD_PAM_AUTH, "PAM_AUTH",
668 winbindd_pam_auth_send, winbindd_pam_auth_recv },
669 { WINBINDD_PAM_LOGOFF, "PAM_LOGOFF",
670 winbindd_pam_logoff_send, winbindd_pam_logoff_recv },
671 { WINBINDD_PAM_CHAUTHTOK, "PAM_CHAUTHTOK",
672 winbindd_pam_chauthtok_send, winbindd_pam_chauthtok_recv },
673 { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, "PAM_CHNG_PSWD_AUTH_CRAP",
674 winbindd_pam_chng_pswd_auth_crap_send,
675 winbindd_pam_chng_pswd_auth_crap_recv },
676 { WINBINDD_WINS_BYIP, "WINS_BYIP",
677 winbindd_wins_byip_send, winbindd_wins_byip_recv },
678 { WINBINDD_WINS_BYNAME, "WINS_BYNAME",
679 winbindd_wins_byname_send, winbindd_wins_byname_recv },
681 { 0, NULL, NULL, NULL }
684 static struct winbindd_async_dispatch_table async_priv_table[] = {
685 { WINBINDD_ALLOCATE_UID, "ALLOCATE_UID",
686 winbindd_allocate_uid_send, winbindd_allocate_uid_recv },
687 { WINBINDD_ALLOCATE_GID, "ALLOCATE_GID",
688 winbindd_allocate_gid_send, winbindd_allocate_gid_recv },
689 { WINBINDD_CHANGE_MACHACC, "CHANGE_MACHACC",
690 winbindd_change_machine_acct_send, winbindd_change_machine_acct_recv },
691 { WINBINDD_PAM_AUTH_CRAP, "PAM_AUTH_CRAP",
692 winbindd_pam_auth_crap_send, winbindd_pam_auth_crap_recv },
694 { 0, NULL, NULL, NULL }
697 static void wb_request_done(struct tevent_req *req);
699 static void process_request(struct winbindd_cli_state *state)
701 struct winbindd_dispatch_table *table = dispatch_table;
702 struct winbindd_async_dispatch_table *atable;
704 state->mem_ctx = talloc_named(state, 0, "winbind request");
705 if (state->mem_ctx == NULL)
708 /* Remember who asked us. */
709 state->pid = state->request->pid;
711 state->cmd_name = "unknown request";
712 state->recv_fn = NULL;
713 /* client is newest */
714 winbindd_promote_client(state);
716 /* Process command */
718 for (atable = async_nonpriv_table; atable->send_req; atable += 1) {
719 if (state->request->cmd == atable->cmd) {
724 if ((atable->send_req == NULL) && state->privileged) {
725 for (atable = async_priv_table; atable->send_req;
727 if (state->request->cmd == atable->cmd) {
733 if (atable->send_req != NULL) {
734 struct tevent_req *req;
736 state->cmd_name = atable->cmd_name;
737 state->recv_fn = atable->recv_req;
739 DEBUG(10, ("process_request: Handling async request %d:%s\n",
740 (int)state->pid, state->cmd_name));
742 req = atable->send_req(state->mem_ctx, winbind_event_context(),
743 state, state->request);
745 DEBUG(0, ("process_request: atable->send failed for "
746 "%s\n", atable->cmd_name));
747 request_error(state);
750 tevent_req_set_callback(req, wb_request_done, state);
754 state->response = talloc_zero(state->mem_ctx,
755 struct winbindd_response);
756 if (state->response == NULL) {
757 DEBUG(10, ("talloc failed\n"));
758 remove_client(state);
761 state->response->result = WINBINDD_PENDING;
762 state->response->length = sizeof(struct winbindd_response);
764 for (table = dispatch_table; table->fn; table++) {
765 if (state->request->cmd == table->cmd) {
766 DEBUG(10,("process_request: request fn %s\n",
767 table->winbindd_cmd_name ));
768 state->cmd_name = table->winbindd_cmd_name;
775 DEBUG(10,("process_request: unknown request fn number %d\n",
776 (int)state->request->cmd ));
777 request_error(state);
781 static void wb_request_done(struct tevent_req *req)
783 struct winbindd_cli_state *state = tevent_req_callback_data(
784 req, struct winbindd_cli_state);
787 state->response = talloc_zero(state->mem_ctx,
788 struct winbindd_response);
789 if (state->response == NULL) {
790 DEBUG(0, ("wb_request_done[%d:%s]: talloc_zero failed - removing client\n",
791 (int)state->pid, state->cmd_name));
792 remove_client(state);
795 state->response->result = WINBINDD_PENDING;
796 state->response->length = sizeof(struct winbindd_response);
798 status = state->recv_fn(req, state->response);
801 DEBUG(10,("wb_request_done[%d:%s]: %s\n",
802 (int)state->pid, state->cmd_name, nt_errstr(status)));
804 if (!NT_STATUS_IS_OK(status)) {
805 request_error(state);
812 * This is the main event loop of winbind requests. It goes through a
813 * state-machine of 3 read/write requests, 4 if you have extra data to send.
815 * An idle winbind client has a read request of 4 bytes outstanding,
816 * finalizing function is request_len_recv, checking the length. request_recv
817 * then processes the packet. The processing function then at some point has
818 * to call request_finished which schedules sending the response.
821 static void request_finished(struct winbindd_cli_state *state);
823 static void winbind_client_request_read(struct tevent_req *req);
824 static void winbind_client_response_written(struct tevent_req *req);
825 static void winbind_client_activity(struct tevent_req *req);
827 static void request_finished(struct winbindd_cli_state *state)
829 struct tevent_req *req;
831 /* free client socket monitoring request */
832 TALLOC_FREE(state->io_req);
834 TALLOC_FREE(state->request);
836 req = wb_resp_write_send(state, winbind_event_context(),
837 state->out_queue, state->sock,
840 DEBUG(10,("request_finished[%d:%s]: wb_resp_write_send() failed\n",
841 (int)state->pid, state->cmd_name));
842 remove_client(state);
845 tevent_req_set_callback(req, winbind_client_response_written, state);
849 static void winbind_client_response_written(struct tevent_req *req)
851 struct winbindd_cli_state *state = tevent_req_callback_data(
852 req, struct winbindd_cli_state);
856 state->io_req = NULL;
858 ret = wb_resp_write_recv(req, &err);
863 DEBUG(2, ("Could not write response[%d:%s] to client: %s\n",
864 (int)state->pid, state->cmd_name, strerror(err)));
865 remove_client(state);
869 DEBUG(10,("winbind_client_response_written[%d:%s]: delivered response "
870 "to client\n", (int)state->pid, state->cmd_name));
872 TALLOC_FREE(state->mem_ctx);
873 state->response = NULL;
874 state->cmd_name = "no request";
875 state->recv_fn = NULL;
877 req = wb_req_read_send(state, winbind_event_context(), state->sock,
878 WINBINDD_MAX_EXTRA_DATA);
880 remove_client(state);
883 tevent_req_set_callback(req, winbind_client_request_read, state);
887 void request_error(struct winbindd_cli_state *state)
889 SMB_ASSERT(state->response->result == WINBINDD_PENDING);
890 state->response->result = WINBINDD_ERROR;
891 request_finished(state);
894 void request_ok(struct winbindd_cli_state *state)
896 SMB_ASSERT(state->response->result == WINBINDD_PENDING);
897 state->response->result = WINBINDD_OK;
898 request_finished(state);
901 /* Process a new connection by adding it to the client connection list */
903 static void new_connection(int listen_sock, bool privileged)
905 struct sockaddr_un sunaddr;
906 struct winbindd_cli_state *state;
907 struct tevent_req *req;
911 /* Accept connection */
913 len = sizeof(sunaddr);
915 sock = accept(listen_sock, (struct sockaddr *)(void *)&sunaddr, &len);
918 if (errno != EINTR) {
919 DEBUG(0, ("Failed to accept socket - %s\n",
925 DEBUG(6,("accepted socket %d\n", sock));
927 /* Create new connection structure */
929 if ((state = talloc_zero(NULL, struct winbindd_cli_state)) == NULL) {
936 state->out_queue = tevent_queue_create(state, "winbind client reply");
937 if (state->out_queue == NULL) {
943 state->privileged = privileged;
945 req = wb_req_read_send(state, winbind_event_context(), state->sock,
946 WINBINDD_MAX_EXTRA_DATA);
952 tevent_req_set_callback(req, winbind_client_request_read, state);
955 /* Add to connection list */
957 winbindd_add_client(state);
960 static void winbind_client_request_read(struct tevent_req *req)
962 struct winbindd_cli_state *state = tevent_req_callback_data(
963 req, struct winbindd_cli_state);
967 state->io_req = NULL;
969 ret = wb_req_read_recv(req, state, &state->request, &err);
973 DEBUG(6, ("closing socket %d, client exited\n",
976 DEBUG(2, ("Could not read client request from fd %d: "
977 "%s\n", state->sock, strerror(err)));
981 remove_client(state);
985 req = wait_for_read_send(state, winbind_event_context(), state->sock,
988 DEBUG(0, ("winbind_client_request_read[%d:%s]:"
989 " wait_for_read_send failed - removing client\n",
990 (int)state->pid, state->cmd_name));
991 remove_client(state);
994 tevent_req_set_callback(req, winbind_client_activity, state);
997 process_request(state);
1000 static void winbind_client_activity(struct tevent_req *req)
1002 struct winbindd_cli_state *state =
1003 tevent_req_callback_data(req, struct winbindd_cli_state);
1007 has_data = wait_for_read_recv(req, &err);
1010 DEBUG(0, ("winbind_client_activity[%d:%s]:"
1011 "unexpected data from client - removing client\n",
1012 (int)state->pid, state->cmd_name));
1015 DEBUG(6, ("winbind_client_activity[%d:%s]: "
1016 "client has closed connection - removing "
1018 (int)state->pid, state->cmd_name));
1020 DEBUG(2, ("winbind_client_activity[%d:%s]: "
1021 "client socket error (%s) - removing "
1023 (int)state->pid, state->cmd_name,
1028 remove_client(state);
1031 /* Remove a client connection from client connection list */
1033 static void remove_client(struct winbindd_cli_state *state)
1038 /* It's a dead client - hold a funeral */
1040 if (state == NULL) {
1045 * We need to remove a pending wb_req_read_*
1046 * or wb_resp_write_* request before closing the
1049 * This is important as they might have used tevent_add_fd() and we
1050 * use the epoll * backend on linux. So we must remove the tevent_fd
1051 * before closing the fd.
1053 * Otherwise we might hit a race with close_conns_after_fork() (via
1054 * winbindd_reinit_after_fork()) where a file description
1055 * is still open in a child, which means it's still active in
1056 * the parents epoll queue, but the related tevent_fd is already
1057 * already gone in the parent.
1061 TALLOC_FREE(state->io_req);
1063 if (state->sock != -1) {
1064 /* tell client, we are closing ... */
1065 nwritten = write(state->sock, &c, sizeof(c));
1066 if (nwritten == -1) {
1067 DEBUG(2, ("final write to client failed: %s\n",
1077 TALLOC_FREE(state->mem_ctx);
1079 /* Remove from list and free */
1081 winbindd_remove_client(state);
1085 /* Is a client idle? */
1087 static bool client_is_idle(struct winbindd_cli_state *state) {
1088 return (state->request == NULL &&
1089 state->response == NULL &&
1090 !state->pwent_state && !state->grent_state);
1093 /* Shutdown client connection which has been idle for the longest time */
1095 static bool remove_idle_client(void)
1097 struct winbindd_cli_state *state, *remove_state = NULL;
1100 for (state = winbindd_client_list(); state; state = state->next) {
1101 if (client_is_idle(state)) {
1103 /* list is sorted by access time */
1104 remove_state = state;
1109 DEBUG(5,("Found %d idle client connections, shutting down sock %d, pid %u\n",
1110 nidle, remove_state->sock, (unsigned int)remove_state->pid));
1111 remove_client(remove_state);
1119 * Terminate all clients whose requests have taken longer than
1120 * "winbind request timeout" seconds to process, or have been
1121 * idle for more than "winbind request timeout" seconds.
1124 static void remove_timed_out_clients(void)
1126 struct winbindd_cli_state *state, *prev = NULL;
1127 time_t curr_time = time(NULL);
1128 int timeout_val = lp_winbind_request_timeout();
1130 for (state = winbindd_client_list_tail(); state; state = prev) {
1133 prev = winbindd_client_list_prev(state);
1134 expiry_time = state->last_access + timeout_val;
1136 if (curr_time > expiry_time) {
1137 if (client_is_idle(state)) {
1138 DEBUG(5,("Idle client timed out, "
1139 "shutting down sock %d, pid %u\n",
1141 (unsigned int)state->pid));
1143 DEBUG(5,("Client request timed out, "
1144 "shutting down sock %d, pid %u\n",
1146 (unsigned int)state->pid));
1148 remove_client(state);
1150 /* list is sorted, previous clients in
1157 static void winbindd_scrub_clients_handler(struct tevent_context *ev,
1158 struct tevent_timer *te,
1159 struct timeval current_time,
1162 remove_timed_out_clients();
1163 if (tevent_add_timer(ev, ev,
1164 timeval_current_ofs(SCRUB_CLIENTS_INTERVAL, 0),
1165 winbindd_scrub_clients_handler, NULL) == NULL) {
1166 DEBUG(0, ("winbindd: failed to reschedule client scrubber\n"));
1171 struct winbindd_listen_state {
1176 static void winbindd_listen_fde_handler(struct tevent_context *ev,
1177 struct tevent_fd *fde,
1181 struct winbindd_listen_state *s = talloc_get_type_abort(private_data,
1182 struct winbindd_listen_state);
1184 while (winbindd_num_clients() > lp_winbind_max_clients() - 1) {
1185 DEBUG(5,("winbindd: Exceeding %d client "
1186 "connections, removing idle "
1187 "connection.\n", lp_winbind_max_clients()));
1188 if (!remove_idle_client()) {
1189 DEBUG(0,("winbindd: Exceeding %d "
1190 "client connections, no idle "
1191 "connection found\n",
1192 lp_winbind_max_clients()));
1196 remove_timed_out_clients();
1197 new_connection(s->fd, s->privileged);
1201 * Winbindd socket accessor functions
1204 char *get_winbind_priv_pipe_dir(void)
1206 return state_path(WINBINDD_PRIV_SOCKET_SUBDIR);
1209 static void winbindd_setup_max_fds(void)
1211 int num_fds = MAX_OPEN_FUDGEFACTOR;
1214 num_fds += lp_winbind_max_clients();
1215 /* Add some more to account for 2 sockets open
1216 when the client transitions from unprivileged
1217 to privileged socket
1219 num_fds += lp_winbind_max_clients() / 10;
1221 /* Add one socket per child process
1222 (yeah there are child processes other than the
1223 domain children but only domain children can vary
1226 num_fds += lp_winbind_max_domain_connections() *
1227 (lp_allow_trusted_domains() ? WINBIND_MAX_DOMAINS_HINT : 1);
1229 actual_fds = set_maxfiles(num_fds);
1231 if (actual_fds < num_fds) {
1232 DEBUG(1, ("winbindd_setup_max_fds: Information only: "
1233 "requested %d open files, %d are available.\n",
1234 num_fds, actual_fds));
1238 static bool winbindd_setup_listeners(void)
1240 struct winbindd_listen_state *pub_state = NULL;
1241 struct winbindd_listen_state *priv_state = NULL;
1242 struct tevent_fd *fde;
1246 pub_state = talloc(winbind_event_context(),
1247 struct winbindd_listen_state);
1252 pub_state->privileged = false;
1253 pub_state->fd = create_pipe_sock(
1254 lp_winbindd_socket_directory(), WINBINDD_SOCKET_NAME, 0755);
1255 if (pub_state->fd == -1) {
1258 rc = listen(pub_state->fd, 5);
1263 fde = tevent_add_fd(winbind_event_context(), pub_state, pub_state->fd,
1264 TEVENT_FD_READ, winbindd_listen_fde_handler,
1267 close(pub_state->fd);
1270 tevent_fd_set_auto_close(fde);
1272 priv_state = talloc(winbind_event_context(),
1273 struct winbindd_listen_state);
1278 socket_path = get_winbind_priv_pipe_dir();
1279 if (socket_path == NULL) {
1283 priv_state->privileged = true;
1284 priv_state->fd = create_pipe_sock(
1285 socket_path, WINBINDD_SOCKET_NAME, 0750);
1286 TALLOC_FREE(socket_path);
1287 if (priv_state->fd == -1) {
1290 rc = listen(priv_state->fd, 5);
1295 fde = tevent_add_fd(winbind_event_context(), priv_state,
1296 priv_state->fd, TEVENT_FD_READ,
1297 winbindd_listen_fde_handler, priv_state);
1299 close(priv_state->fd);
1302 tevent_fd_set_auto_close(fde);
1304 winbindd_scrub_clients_handler(winbind_event_context(), NULL,
1305 timeval_current(), NULL);
1308 TALLOC_FREE(pub_state);
1309 TALLOC_FREE(priv_state);
1313 bool winbindd_use_idmap_cache(void)
1315 return !opt_nocache;
1318 bool winbindd_use_cache(void)
1320 return !opt_nocache;
1323 static void winbindd_register_handlers(struct messaging_context *msg_ctx,
1327 /* Setup signal handlers */
1329 if (!winbindd_setup_sig_term_handler(true))
1331 if (!winbindd_setup_stdin_handler(true, foreground))
1333 if (!winbindd_setup_sig_hup_handler(NULL))
1335 if (!winbindd_setup_sig_chld_handler())
1337 if (!winbindd_setup_sig_usr2_handler())
1340 CatchSignal(SIGPIPE, SIG_IGN); /* Ignore sigpipe */
1343 * Ensure all cache and idmap caches are consistent
1344 * and initialized before we startup.
1346 if (!winbindd_cache_validate_and_initialize()) {
1350 /* get broadcast messages */
1352 if (!serverid_register(messaging_server_id(msg_ctx),
1356 DEBUG(1, ("Could not register myself in serverid.tdb\n"));
1360 /* React on 'smbcontrol winbindd reload-config' in the same way
1361 as to SIGHUP signal */
1362 messaging_register(msg_ctx, NULL,
1363 MSG_SMB_CONF_UPDATED, msg_reload_services);
1364 messaging_register(msg_ctx, NULL,
1365 MSG_SHUTDOWN, msg_shutdown);
1367 /* Handle online/offline messages. */
1368 messaging_register(msg_ctx, NULL,
1369 MSG_WINBIND_OFFLINE, winbind_msg_offline);
1370 messaging_register(msg_ctx, NULL,
1371 MSG_WINBIND_ONLINE, winbind_msg_online);
1372 messaging_register(msg_ctx, NULL,
1373 MSG_WINBIND_ONLINESTATUS, winbind_msg_onlinestatus);
1375 /* Handle domain online/offline messages for domains */
1376 messaging_register(winbind_messaging_context(), NULL,
1377 MSG_WINBIND_DOMAIN_OFFLINE, winbind_msg_domain_offline);
1378 messaging_register(winbind_messaging_context(), NULL,
1379 MSG_WINBIND_DOMAIN_ONLINE, winbind_msg_domain_online);
1381 messaging_register(msg_ctx, NULL,
1382 MSG_DUMP_EVENT_LIST, winbind_msg_dump_event_list);
1384 messaging_register(msg_ctx, NULL,
1385 MSG_WINBIND_VALIDATE_CACHE,
1386 winbind_msg_validate_cache);
1388 messaging_register(msg_ctx, NULL,
1389 MSG_WINBIND_DUMP_DOMAIN_LIST,
1390 winbind_msg_dump_domain_list);
1392 messaging_register(msg_ctx, NULL,
1393 MSG_WINBIND_IP_DROPPED,
1394 winbind_msg_ip_dropped_parent);
1396 /* Register handler for MSG_DEBUG. */
1397 messaging_register(msg_ctx, NULL,
1401 netsamlogon_cache_init(); /* Non-critical */
1403 /* clear the cached list of trusted domains */
1407 if (!init_domain_list()) {
1408 DEBUG(0,("unable to initialize domain list\n"));
1413 init_locator_child();
1415 smb_nscd_flush_user_cache();
1416 smb_nscd_flush_group_cache();
1418 if (lp_allow_trusted_domains()) {
1419 if (tevent_add_timer(winbind_event_context(), NULL, timeval_zero(),
1420 rescan_trusted_domains, NULL) == NULL) {
1421 DEBUG(0, ("Could not trigger rescan_trusted_domains()\n"));
1426 status = wb_irpc_register();
1428 if (!NT_STATUS_IS_OK(status)) {
1429 DEBUG(0, ("Could not register IRPC handlers\n"));
1434 struct winbindd_addrchanged_state {
1435 struct addrchange_context *ctx;
1436 struct tevent_context *ev;
1437 struct messaging_context *msg_ctx;
1440 static void winbindd_addr_changed(struct tevent_req *req);
1442 static void winbindd_init_addrchange(TALLOC_CTX *mem_ctx,
1443 struct tevent_context *ev,
1444 struct messaging_context *msg_ctx)
1446 struct winbindd_addrchanged_state *state;
1447 struct tevent_req *req;
1450 state = talloc(mem_ctx, struct winbindd_addrchanged_state);
1451 if (state == NULL) {
1452 DEBUG(10, ("talloc failed\n"));
1456 state->msg_ctx = msg_ctx;
1458 status = addrchange_context_create(state, &state->ctx);
1459 if (!NT_STATUS_IS_OK(status)) {
1460 DEBUG(10, ("addrchange_context_create failed: %s\n",
1461 nt_errstr(status)));
1465 req = addrchange_send(state, ev, state->ctx);
1467 DEBUG(0, ("addrchange_send failed\n"));
1471 tevent_req_set_callback(req, winbindd_addr_changed, state);
1474 static void winbindd_addr_changed(struct tevent_req *req)
1476 struct winbindd_addrchanged_state *state = tevent_req_callback_data(
1477 req, struct winbindd_addrchanged_state);
1478 enum addrchange_type type;
1479 struct sockaddr_storage addr;
1482 status = addrchange_recv(req, &type, &addr);
1484 if (!NT_STATUS_IS_OK(status)) {
1485 DEBUG(10, ("addrchange_recv failed: %s, stop listening\n",
1486 nt_errstr(status)));
1490 if (type == ADDRCHANGE_DEL) {
1491 char addrstr[INET6_ADDRSTRLEN];
1494 print_sockaddr(addrstr, sizeof(addrstr), &addr);
1496 DEBUG(3, ("winbindd: kernel (AF_NETLINK) dropped ip %s\n",
1499 blob = data_blob_const(addrstr, strlen(addrstr)+1);
1501 status = messaging_send(state->msg_ctx,
1502 messaging_server_id(state->msg_ctx),
1503 MSG_WINBIND_IP_DROPPED, &blob);
1504 if (!NT_STATUS_IS_OK(status)) {
1505 DEBUG(10, ("messaging_send failed: %s - ignoring\n",
1506 nt_errstr(status)));
1509 req = addrchange_send(state, state->ev, state->ctx);
1511 DEBUG(0, ("addrchange_send failed\n"));
1515 tevent_req_set_callback(req, winbindd_addr_changed, state);
1520 int main(int argc, const char **argv)
1522 static bool is_daemon = False;
1523 static bool Fork = True;
1524 static bool log_stdout = False;
1525 static bool no_process_group = False;
1529 OPT_NO_PROCESS_GROUP,
1532 struct poptOption long_options[] = {
1534 { "stdout", 'S', POPT_ARG_NONE, NULL, OPT_LOG_STDOUT, "Log to stdout" },
1535 { "foreground", 'F', POPT_ARG_NONE, NULL, OPT_FORK, "Daemon in foreground mode" },
1536 { "no-process-group", 0, POPT_ARG_NONE, NULL, OPT_NO_PROCESS_GROUP, "Don't create a new process group" },
1537 { "daemon", 'D', POPT_ARG_NONE, NULL, OPT_DAEMON, "Become a daemon (default)" },
1538 { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
1539 { "no-caching", 'n', POPT_ARG_NONE, NULL, 'n', "Disable caching" },
1550 * Do this before any other talloc operation
1552 talloc_enable_null_tracking();
1553 frame = talloc_stackframe();
1556 * We want total control over the permissions on created files,
1557 * so set our umask to 0.
1561 setup_logging("winbindd", DEBUG_DEFAULT_STDOUT);
1563 /* glibc (?) likes to print "User defined signal 1" and exit if a
1564 SIGUSR[12] is received before a handler is installed */
1566 CatchSignal(SIGUSR1, SIG_IGN);
1567 CatchSignal(SIGUSR2, SIG_IGN);
1570 dump_core_setup("winbindd", lp_logfile(talloc_tos()));
1574 /* Initialise for running in non-root mode */
1578 set_remote_machine_name("winbindd", False);
1580 /* Set environment variable so we don't recursively call ourselves.
1581 This may also be useful interactively. */
1583 if ( !winbind_off() ) {
1584 DEBUG(0,("Failed to disable recusive winbindd calls. Exiting.\n"));
1588 /* Initialise samba/rpc client stuff */
1590 pc = poptGetContext("winbindd", argc, argv, long_options, 0);
1592 while ((opt = poptGetNextOpt(pc)) != -1) {
1594 /* Don't become a daemon */
1606 case OPT_NO_PROCESS_GROUP:
1607 no_process_group = true;
1609 case OPT_LOG_STDOUT:
1616 d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
1617 poptBadOption(pc, 0), poptStrerror(opt));
1618 poptPrintUsage(pc, stderr, 0);
1623 /* We call dump_core_setup one more time because the command line can
1624 * set the log file or the log-basename and this will influence where
1625 * cores are stored. Without this call get_dyn_LOGFILEBASE will be
1626 * the default value derived from build's prefix. For EOM this value
1627 * is often not related to the path where winbindd is actually run
1630 dump_core_setup("winbindd", lp_logfile(talloc_tos()));
1631 if (is_daemon && interactive) {
1632 d_fprintf(stderr,"\nERROR: "
1633 "Option -i|--interactive is not allowed together with -D|--daemon\n\n");
1634 poptPrintUsage(pc, stderr, 0);
1638 if (log_stdout && Fork) {
1639 d_fprintf(stderr, "\nERROR: "
1640 "Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n\n");
1641 poptPrintUsage(pc, stderr, 0);
1645 poptFreeContext(pc);
1647 if (!override_logfile) {
1649 if (asprintf(&lfile,"%s/log.winbindd",
1650 get_dyn_LOGFILEBASE()) > 0) {
1651 lp_set_logfile(lfile);
1657 setup_logging("winbindd", DEBUG_STDOUT);
1659 setup_logging("winbindd", DEBUG_FILE);
1663 DEBUG(0,("winbindd version %s started.\n", samba_version_string()));
1664 DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
1666 if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
1667 DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE()));
1670 /* After parsing the configuration file we setup the core path one more time
1671 * as the log file might have been set in the configuration and cores's
1672 * path is by default basename(lp_logfile()).
1674 dump_core_setup("winbindd", lp_logfile(talloc_tos()));
1676 if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC
1677 && !lp_parm_bool(-1, "server role check", "inhibit", false)) {
1678 DEBUG(0, ("server role = 'active directory domain controller' not compatible with running the winbindd binary. \n"));
1679 DEBUGADD(0, ("You should start 'samba' instead, and it will control starting the internal AD DC winbindd implementation, which is not the same as this one\n"));
1683 if (!cluster_probe_ok()) {
1687 /* Initialise messaging system */
1689 if (winbind_messaging_context() == NULL) {
1693 if (!reload_services_file(NULL)) {
1694 DEBUG(0, ("error opening config file\n"));
1698 ok = directory_create_or_exist(lp_lock_directory(), 0755);
1700 DEBUG(0, ("Failed to create directory %s for lock files - %s\n",
1701 lp_lock_directory(), strerror(errno)));
1705 ok = directory_create_or_exist(lp_pid_directory(), 0755);
1707 DEBUG(0, ("Failed to create directory %s for pid files - %s\n",
1708 lp_pid_directory(), strerror(errno)));
1719 if (!secrets_init()) {
1721 DEBUG(0,("Could not initialize domain trust account secrets. Giving up\n"));
1725 status = rpccli_pre_open_netlogon_creds();
1726 if (!NT_STATUS_IS_OK(status)) {
1727 DEBUG(0, ("rpccli_pre_open_netlogon_creds() - %s\n",
1728 nt_errstr(status)));
1732 /* Unblock all signals we are interested in as they may have been
1733 blocked by the parent process. */
1735 BlockSignals(False, SIGINT);
1736 BlockSignals(False, SIGQUIT);
1737 BlockSignals(False, SIGTERM);
1738 BlockSignals(False, SIGUSR1);
1739 BlockSignals(False, SIGUSR2);
1740 BlockSignals(False, SIGHUP);
1741 BlockSignals(False, SIGCHLD);
1744 become_daemon(Fork, no_process_group, log_stdout);
1746 pidfile_create(lp_pid_directory(), "winbindd");
1750 * If we're interactive we want to set our own process group for
1751 * signal management.
1753 if (interactive && !no_process_group)
1754 setpgid( (pid_t)0, (pid_t)0);
1759 /* Don't use winbindd_reinit_after_fork here as
1760 * we're just starting up and haven't created any
1761 * winbindd-specific resources we must free yet. JRA.
1764 status = reinit_after_fork(winbind_messaging_context(),
1765 winbind_event_context(),
1767 if (!NT_STATUS_IS_OK(status)) {
1768 exit_daemon("Winbindd reinit_after_fork() failed", map_errno_from_nt_status(status));
1772 * Do not initialize the parent-child-pipe before becoming
1773 * a daemon: this is used to detect a died parent in the child
1776 status = init_before_fork();
1777 if (!NT_STATUS_IS_OK(status)) {
1778 exit_daemon(nt_errstr(status), map_errno_from_nt_status(status));
1781 winbindd_register_handlers(winbind_messaging_context(), !Fork);
1783 if (!messaging_parent_dgm_cleanup_init(winbind_messaging_context())) {
1787 status = init_system_session_info();
1788 if (!NT_STATUS_IS_OK(status)) {
1789 exit_daemon("Winbindd failed to setup system user info", map_errno_from_nt_status(status));
1792 rpc_lsarpc_init(NULL);
1793 rpc_samr_init(NULL);
1795 winbindd_init_addrchange(NULL, winbind_event_context(),
1796 winbind_messaging_context());
1798 /* setup listen sockets */
1800 if (!winbindd_setup_listeners()) {
1801 exit_daemon("Winbindd failed to setup listeners", EPIPE);
1804 irpc_add_name(winbind_imessaging_context(), "winbind_server");
1809 daemon_ready("winbindd");
1812 /* Loop waiting for requests */
1814 frame = talloc_stackframe();
1816 if (tevent_loop_once(winbind_event_context()) == -1) {
1817 DEBUG(1, ("tevent_loop_once() failed: %s\n",