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 2 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, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 BOOL opt_nocache = False;
30 static BOOL interactive = False;
32 extern BOOL override_logfile;
34 /* Reload configuration */
36 static BOOL reload_services_file(void)
43 pstrcpy(fname,lp_configfile());
44 if (file_exist(fname,NULL) && !strcsequal(fname,dyn_CONFIGFILE)) {
45 pstrcpy(dyn_CONFIGFILE,fname);
50 ret = lp_load(dyn_CONFIGFILE,False,False,True);
61 /**************************************************************************** **
62 Prepare to dump a core file - carefully!
63 **************************************************************************** */
65 static BOOL dump_core(void)
69 pstrcpy( dname, lp_logfile() );
70 if ((p=strrchr(dname,'/')))
72 pstrcat( dname, "/corefiles" );
74 sys_chown( dname, getuid(), getgid() );
84 getrlimit( RLIMIT_CORE, &rlp );
85 rlp.rlim_cur = MAX( 4*1024*1024, rlp.rlim_cur );
86 setrlimit( RLIMIT_CORE, &rlp );
87 getrlimit( RLIMIT_CORE, &rlp );
88 DEBUG( 3, ( "Core limits now %d %d\n", (int)rlp.rlim_cur, (int)rlp.rlim_max ) );
93 DEBUG(0,("Dumping core in %s\n",dname));
99 /**************************************************************************** **
101 **************************************************************************** */
103 static void fault_quit(void)
110 static void winbindd_status(void)
112 struct winbindd_cli_state *tmp;
114 DEBUG(0, ("winbindd status:\n"));
116 /* Print client state information */
118 DEBUG(0, ("\t%d clients currently active\n", winbindd_num_clients()));
120 if (DEBUGLEVEL >= 2 && winbindd_num_clients()) {
121 DEBUG(2, ("\tclient list:\n"));
122 for(tmp = winbindd_client_list(); tmp; tmp = tmp->next) {
123 DEBUG(2, ("\t\tpid %lu, sock %d, rbl %d, wbl %d\n",
124 (unsigned long)tmp->pid, tmp->sock, tmp->read_buf_len,
125 tmp->write_buf_len));
130 /* Print winbindd status to log file */
132 static void print_winbindd_status(void)
137 /* Flush client cache */
139 static void flush_caches(void)
141 /* We need to invalidate cached user list entries on a SIGHUP
142 otherwise cached access denied errors due to restrict anonymous
143 hang around until the sequence number changes. */
145 wcache_invalidate_cache();
148 /* Handle the signal by unlinking socket and exiting */
150 static void terminate(void)
156 /* Remove socket file */
157 pstr_sprintf(path, "%s/%s",
158 WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
163 TALLOC_CTX *mem_ctx = talloc_init("end_description");
164 char *description = talloc_describe_all(mem_ctx);
166 DEBUG(3, ("tallocs left:\n%s\n", description));
167 talloc_destroy(mem_ctx);
174 static BOOL do_sigterm;
176 static void termination_handler(int signum)
179 sys_select_signal(signum);
182 static BOOL do_sigusr2;
184 static void sigusr2_handler(int signum)
187 sys_select_signal(SIGUSR2);
190 static BOOL do_sighup;
192 static void sighup_handler(int signum)
195 sys_select_signal(SIGHUP);
198 static BOOL do_sigchld;
200 static void sigchld_handler(int signum)
203 sys_select_signal(SIGCHLD);
206 /* React on 'smbcontrol winbindd reload-config' in the same way as on SIGHUP*/
207 static void msg_reload_services(int msg_type, pid_t src, void *buf, size_t len)
209 /* Flush various caches */
211 reload_services_file();
214 /* React on 'smbcontrol winbindd shutdown' in the same way as on SIGTERM*/
215 static void msg_shutdown(int msg_type, pid_t src, void *buf, size_t len)
220 static struct winbindd_dispatch_table {
221 enum winbindd_cmd cmd;
222 void (*fn)(struct winbindd_cli_state *state);
223 const char *winbindd_cmd_name;
224 } dispatch_table[] = {
228 { WINBINDD_GETPWNAM, winbindd_getpwnam, "GETPWNAM" },
229 { WINBINDD_GETPWUID, winbindd_getpwuid, "GETPWUID" },
231 { WINBINDD_SETPWENT, winbindd_setpwent, "SETPWENT" },
232 { WINBINDD_ENDPWENT, winbindd_endpwent, "ENDPWENT" },
233 { WINBINDD_GETPWENT, winbindd_getpwent, "GETPWENT" },
235 { WINBINDD_GETGROUPS, winbindd_getgroups, "GETGROUPS" },
236 { WINBINDD_GETUSERSIDS, winbindd_getusersids, "GETUSERSIDS" },
237 { WINBINDD_GETUSERDOMGROUPS, winbindd_getuserdomgroups,
238 "GETUSERDOMGROUPS" },
240 /* Group functions */
242 { WINBINDD_GETGRNAM, winbindd_getgrnam, "GETGRNAM" },
243 { WINBINDD_GETGRGID, winbindd_getgrgid, "GETGRGID" },
244 { WINBINDD_SETGRENT, winbindd_setgrent, "SETGRENT" },
245 { WINBINDD_ENDGRENT, winbindd_endgrent, "ENDGRENT" },
246 { WINBINDD_GETGRENT, winbindd_getgrent, "GETGRENT" },
247 { WINBINDD_GETGRLST, winbindd_getgrent, "GETGRLST" },
249 /* PAM auth functions */
251 { WINBINDD_PAM_AUTH, winbindd_pam_auth, "PAM_AUTH" },
252 { WINBINDD_PAM_AUTH_CRAP, winbindd_pam_auth_crap, "AUTH_CRAP" },
253 { WINBINDD_PAM_CHAUTHTOK, winbindd_pam_chauthtok, "CHAUTHTOK" },
255 /* Enumeration functions */
257 { WINBINDD_LIST_USERS, winbindd_list_users, "LIST_USERS" },
258 { WINBINDD_LIST_GROUPS, winbindd_list_groups, "LIST_GROUPS" },
259 { WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains,
261 { WINBINDD_SHOW_SEQUENCE, winbindd_show_sequence, "SHOW_SEQUENCE" },
263 /* SID related functions */
265 { WINBINDD_LOOKUPSID, winbindd_lookupsid, "LOOKUPSID" },
266 { WINBINDD_LOOKUPNAME, winbindd_lookupname, "LOOKUPNAME" },
268 /* Lookup related functions */
270 { WINBINDD_SID_TO_UID, winbindd_sid_to_uid, "SID_TO_UID" },
271 { WINBINDD_SID_TO_GID, winbindd_sid_to_gid, "SID_TO_GID" },
272 { WINBINDD_UID_TO_SID, winbindd_uid_to_sid, "UID_TO_SID" },
273 { WINBINDD_GID_TO_SID, winbindd_gid_to_sid, "GID_TO_SID" },
274 { WINBINDD_ALLOCATE_RID, winbindd_allocate_rid, "ALLOCATE_RID" },
275 { WINBINDD_ALLOCATE_RID_AND_GID, winbindd_allocate_rid_and_gid,
276 "ALLOCATE_RID_AND_GID" },
280 { WINBINDD_CHECK_MACHACC, winbindd_check_machine_acct, "CHECK_MACHACC" },
281 { WINBINDD_PING, winbindd_ping, "PING" },
282 { WINBINDD_INFO, winbindd_info, "INFO" },
283 { WINBINDD_INTERFACE_VERSION, winbindd_interface_version,
284 "INTERFACE_VERSION" },
285 { WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" },
286 { WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
287 { WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" },
288 { WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
289 "WINBINDD_PRIV_PIPE_DIR" },
290 { WINBINDD_GETDCNAME, winbindd_getdcname, "GETDCNAME" },
294 { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" },
295 { WINBINDD_WINS_BYIP, winbindd_wins_byip, "WINS_BYIP" },
299 { WINBINDD_NUM_CMDS, NULL, "NONE" }
302 static void process_request(struct winbindd_cli_state *state)
304 struct winbindd_dispatch_table *table = dispatch_table;
306 /* Free response data - we may be interrupted and receive another
307 command before being able to send this data off. */
309 SAFE_FREE(state->response.extra_data);
311 ZERO_STRUCT(state->response);
313 state->response.result = WINBINDD_PENDING;
314 state->response.length = sizeof(struct winbindd_response);
316 state->mem_ctx = talloc_init("winbind request");
317 if (state->mem_ctx == NULL)
320 /* Process command */
322 for (table = dispatch_table; table->fn; table++) {
323 if (state->request.cmd == table->cmd) {
324 DEBUG(10,("process_request: request fn %s\n",
325 table->winbindd_cmd_name ));
332 DEBUG(10,("process_request: unknown request fn number %d\n",
333 (int)state->request.cmd ));
334 request_error(state);
339 * A list of file descriptors being monitored by select in the main processing
340 * loop. fd_event->handler is called whenever the socket is readable/writable.
343 static struct fd_event *fd_events = NULL;
345 void add_fd_event(struct fd_event *ev)
347 struct fd_event *match;
349 /* only add unique fd_event structs */
351 for (match=fd_events; match; match=match->next ) {
353 SMB_ASSERT( match != ev );
360 DLIST_ADD(fd_events, ev);
363 void remove_fd_event(struct fd_event *ev)
365 DLIST_REMOVE(fd_events, ev);
369 * Handler for fd_events to complete a read/write request, set up by
370 * setup_async_read/setup_async_write.
373 static void rw_callback(struct fd_event *event, int flags)
378 todo = event->length - event->done;
380 if (event->flags & EVENT_FD_WRITE) {
381 SMB_ASSERT(flags == EVENT_FD_WRITE);
382 done = sys_write(event->fd,
383 &((char *)event->data)[event->done],
388 event->finished(event->private_data, False);
393 if (event->flags & EVENT_FD_READ) {
394 SMB_ASSERT(flags == EVENT_FD_READ);
395 done = sys_read(event->fd, &((char *)event->data)[event->done],
400 event->finished(event->private_data, False);
407 if (event->done == event->length) {
409 event->finished(event->private_data, True);
414 * Request an async read/write on a fd_event structure. (*finished) is called
415 * when the request is completed or an error had occurred.
418 void setup_async_read(struct fd_event *event, void *data, size_t length,
419 void (*finished)(void *private_data, BOOL success),
422 SMB_ASSERT(event->flags == 0);
424 event->length = length;
426 event->handler = rw_callback;
427 event->finished = finished;
428 event->private_data = private_data;
429 event->flags = EVENT_FD_READ;
432 void setup_async_write(struct fd_event *event, void *data, size_t length,
433 void (*finished)(void *private_data, BOOL success),
436 SMB_ASSERT(event->flags == 0);
438 event->length = length;
440 event->handler = rw_callback;
441 event->finished = finished;
442 event->private_data = private_data;
443 event->flags = EVENT_FD_WRITE;
447 * This is the main event loop of winbind requests. It goes through a
448 * state-machine of 3 read/write requests, 4 if you have extra data to send.
450 * An idle winbind client has a read request of 4 bytes outstanding,
451 * finalizing function is request_len_recv, checking the length. request_recv
452 * then processes the packet. The processing function then at some point has
453 * to call request_finished which schedules sending the response.
456 static void request_len_recv(void *private_data, BOOL success);
457 static void request_recv(void *private_data, BOOL success);
458 static void request_finished(struct winbindd_cli_state *state);
459 void request_finished_cont(void *private_data, BOOL success);
460 static void response_main_sent(void *private_data, BOOL success);
461 static void response_extra_sent(void *private_data, BOOL success);
463 static void response_extra_sent(void *private_data, BOOL success)
465 struct winbindd_cli_state *state =
466 talloc_get_type_abort(private_data, struct winbindd_cli_state);
468 if (state->mem_ctx != NULL) {
469 talloc_destroy(state->mem_ctx);
470 state->mem_ctx = NULL;
474 state->finished = True;
478 SAFE_FREE(state->response.extra_data);
480 setup_async_read(&state->fd_event, &state->request, sizeof(uint32),
481 request_len_recv, state);
484 static void response_main_sent(void *private_data, BOOL success)
486 struct winbindd_cli_state *state =
487 talloc_get_type_abort(private_data, struct winbindd_cli_state);
490 state->finished = True;
494 if (state->response.length == sizeof(state->response)) {
495 if (state->mem_ctx != NULL) {
496 talloc_destroy(state->mem_ctx);
497 state->mem_ctx = NULL;
500 setup_async_read(&state->fd_event, &state->request,
501 sizeof(uint32), request_len_recv, state);
505 setup_async_write(&state->fd_event, state->response.extra_data,
506 state->response.length - sizeof(state->response),
507 response_extra_sent, state);
510 static void request_finished(struct winbindd_cli_state *state)
512 setup_async_write(&state->fd_event, &state->response,
513 sizeof(state->response), response_main_sent, state);
516 void request_error(struct winbindd_cli_state *state)
518 SMB_ASSERT(state->response.result == WINBINDD_PENDING);
519 state->response.result = WINBINDD_ERROR;
520 request_finished(state);
523 void request_ok(struct winbindd_cli_state *state)
525 SMB_ASSERT(state->response.result == WINBINDD_PENDING);
526 state->response.result = WINBINDD_OK;
527 request_finished(state);
530 void request_finished_cont(void *private_data, BOOL success)
532 struct winbindd_cli_state *state =
533 talloc_get_type_abort(private_data, struct winbindd_cli_state);
538 request_error(state);
541 static void request_recv(void *private_data, BOOL success)
543 struct winbindd_cli_state *state =
544 talloc_get_type_abort(private_data, struct winbindd_cli_state);
547 state->finished = True;
551 process_request(state);
554 static void request_len_recv(void *private_data, BOOL success)
556 struct winbindd_cli_state *state =
557 talloc_get_type_abort(private_data, struct winbindd_cli_state);
560 state->finished = True;
564 if (*(uint32 *)(&state->request) != sizeof(state->request)) {
565 DEBUG(0,("request_len_recv: Invalid request size received: %d\n",
566 *(uint32 *)(&state->request)));
567 state->finished = True;
571 setup_async_read(&state->fd_event, (uint32 *)(&state->request)+1,
572 sizeof(state->request) - sizeof(uint32),
573 request_recv, state);
576 /* Process a new connection by adding it to the client connection list */
578 static void new_connection(int listen_sock, BOOL privileged)
580 struct sockaddr_un sunaddr;
581 struct winbindd_cli_state *state;
585 /* Accept connection */
587 len = sizeof(sunaddr);
590 sock = accept(listen_sock, (struct sockaddr *)&sunaddr, &len);
591 } while (sock == -1 && errno == EINTR);
596 DEBUG(6,("accepted socket %d\n", sock));
598 /* Create new connection structure */
600 if ((state = TALLOC_ZERO_P(NULL, struct winbindd_cli_state)) == NULL)
605 state->last_access = time(NULL);
607 state->privileged = privileged;
609 state->fd_event.fd = state->sock;
610 state->fd_event.flags = 0;
611 add_fd_event(&state->fd_event);
613 setup_async_read(&state->fd_event, &state->request, sizeof(uint32),
614 request_len_recv, state);
616 /* Add to connection list */
618 winbindd_add_client(state);
621 /* Remove a client connection from client connection list */
623 static void remove_client(struct winbindd_cli_state *state)
625 /* It's a dead client - hold a funeral */
633 /* Free any getent state */
635 free_getent_state(state->getpwent_state);
636 free_getent_state(state->getgrent_state);
638 /* We may have some extra data that was not freed if the
639 client was killed unexpectedly */
641 SAFE_FREE(state->response.extra_data);
643 if (state->mem_ctx != NULL) {
644 talloc_destroy(state->mem_ctx);
645 state->mem_ctx = NULL;
648 remove_fd_event(&state->fd_event);
650 /* Remove from list and free */
652 winbindd_remove_client(state);
658 /* Shutdown client connection which has been idle for the longest time */
660 static BOOL remove_idle_client(void)
662 struct winbindd_cli_state *state, *remove_state = NULL;
663 time_t last_access = 0;
666 for (state = winbindd_client_list(); state; state = state->next) {
667 if (state->read_buf_len == 0 && state->write_buf_len == 0 &&
668 state->response.result != WINBINDD_PENDING &&
669 !state->getpwent_state && !state->getgrent_state) {
671 if (!last_access || state->last_access < last_access) {
672 last_access = state->last_access;
673 remove_state = state;
679 DEBUG(5,("Found %d idle client connections, shutting down sock %d, pid %u\n",
680 nidle, remove_state->sock, (unsigned int)remove_state->pid));
681 remove_client(remove_state);
688 /* Process incoming clients on listen_sock. We use a tricky non-blocking,
689 non-forking, non-threaded model which allows us to handle many
690 simultaneous connections while remaining impervious to many denial of
693 static void process_loop(void)
695 struct winbindd_cli_state *state;
698 int maxfd, listen_sock, listen_priv_sock, selret;
699 struct timeval timeout;
701 /* We'll be doing this a lot */
703 /* Handle messages */
707 /* refresh the trusted domain cache */
709 rescan_trusted_domains();
711 /* Free up temporary memory */
714 main_loop_talloc_free();
716 /* Initialise fd lists for select() */
718 listen_sock = open_winbindd_socket();
719 listen_priv_sock = open_winbindd_priv_socket();
721 if (listen_sock == -1 || listen_priv_sock == -1) {
722 perror("open_winbind_socket");
726 maxfd = MAX(listen_sock, listen_priv_sock);
730 FD_SET(listen_sock, &r_fds);
731 FD_SET(listen_priv_sock, &r_fds);
733 timeout.tv_sec = WINBINDD_ESTABLISH_LOOP;
736 /* Set up client readers and writers */
738 state = winbindd_client_list();
742 struct winbindd_cli_state *next = state->next;
744 /* Dispose of client connection if it is marked as
748 remove_client(state);
753 for (ev = fd_events; ev; ev = ev->next) {
754 if (ev->flags & EVENT_FD_READ) {
755 FD_SET(ev->fd, &r_fds);
756 maxfd = MAX(ev->fd, maxfd);
758 if (ev->flags & EVENT_FD_WRITE) {
759 FD_SET(ev->fd, &w_fds);
760 maxfd = MAX(ev->fd, maxfd);
766 selret = sys_select(maxfd + 1, &r_fds, &w_fds, NULL, &timeout);
771 if ((selret == -1 && errno != EINTR) || selret == 0) {
773 /* Select error, something is badly wrong */
781 struct fd_event *next = ev->next;
783 if (FD_ISSET(ev->fd, &r_fds))
784 flags |= EVENT_FD_READ;
785 if (FD_ISSET(ev->fd, &w_fds))
786 flags |= EVENT_FD_WRITE;
788 ev->handler(ev, flags);
792 if (FD_ISSET(listen_sock, &r_fds)) {
793 while (winbindd_num_clients() >
794 WINBINDD_MAX_SIMULTANEOUS_CLIENTS - 1) {
795 DEBUG(5,("winbindd: Exceeding %d client "
796 "connections, removing idle "
798 WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
799 if (!remove_idle_client()) {
800 DEBUG(0,("winbindd: Exceeding %d "
801 "client connections, no idle "
802 "connection found\n",
803 WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
807 /* new, non-privileged connection */
808 new_connection(listen_sock, False);
811 if (FD_ISSET(listen_priv_sock, &r_fds)) {
812 while (winbindd_num_clients() >
813 WINBINDD_MAX_SIMULTANEOUS_CLIENTS - 1) {
814 DEBUG(5,("winbindd: Exceeding %d client "
815 "connections, removing idle "
817 WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
818 if (!remove_idle_client()) {
819 DEBUG(0,("winbindd: Exceeding %d "
820 "client connections, no idle "
821 "connection found\n",
822 WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
826 /* new, privileged connection */
827 new_connection(listen_priv_sock, True);
833 winbindd_check_cache_size(time(NULL));
836 /* Check signal handling things */
843 DEBUG(3, ("got SIGHUP\n"));
845 msg_reload_services(MSG_SMB_CONF_UPDATED, (pid_t) 0, NULL, 0);
850 print_winbindd_status();
859 while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) {
860 winbind_child_died(pid);
867 struct winbindd_state server_state; /* Server state information */
869 int main(int argc, char **argv)
872 static BOOL Fork = True;
873 static BOOL log_stdout = False;
874 struct poptOption long_options[] = {
876 { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
877 { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" },
878 { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
879 { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, True, "Disable caching" },
886 /* glibc (?) likes to print "User defined signal 1" and exit if a
887 SIGUSR[12] is received before a handler is installed */
889 CatchSignal(SIGUSR1, SIG_IGN);
890 CatchSignal(SIGUSR2, SIG_IGN);
892 fault_setup((void (*)(void *))fault_quit );
894 /* Initialise for running in non-root mode */
898 set_remote_machine_name("winbindd", False);
900 /* Set environment variable so we don't recursively call ourselves.
901 This may also be useful interactively. */
903 setenv(WINBINDD_DONT_ENV, "1", 1);
905 /* Initialise samba/rpc client stuff */
907 pc = poptGetContext("winbindd", argc, (const char **)argv, long_options,
908 POPT_CONTEXT_KEEP_FIRST);
910 while ((opt = poptGetNextOpt(pc)) != -1) {
912 /* Don't become a daemon */
922 if (log_stdout && Fork) {
923 printf("Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n");
924 poptPrintUsage(pc, stderr, 0);
928 if (!override_logfile) {
929 pstr_sprintf(logfile, "%s/log.winbindd", dyn_LOGFILEBASE);
930 lp_set_logfile(logfile);
932 setup_logging("winbindd", log_stdout);
935 DEBUG(1, ("winbindd version %s started.\n", SAMBA_VERSION_STRING) );
936 DEBUGADD( 1, ( "Copyright The Samba Team 2000-2004\n" ) );
938 if (!reload_services_file()) {
939 DEBUG(0, ("error opening config file\n"));
950 if (!secrets_init()) {
952 DEBUG(0,("Could not initialize domain trust account secrets. Giving up\n"));
956 /* Enable netbios namecache */
960 /* Check winbindd parameters are valid */
962 ZERO_STRUCT(server_state);
964 /* Winbind daemon initialisation */
966 if ( (!winbindd_param_init()) || (!winbindd_upgrade_idmap()) ||
967 (!idmap_init(lp_idmap_backend())) ) {
968 DEBUG(1, ("Could not init idmap -- netlogon proxy only\n"));
969 idmap_set_proxyonly();
972 /* Unblock all signals we are interested in as they may have been
973 blocked by the parent process. */
975 BlockSignals(False, SIGINT);
976 BlockSignals(False, SIGQUIT);
977 BlockSignals(False, SIGTERM);
978 BlockSignals(False, SIGUSR1);
979 BlockSignals(False, SIGUSR2);
980 BlockSignals(False, SIGHUP);
981 BlockSignals(False, SIGCHLD);
983 /* Setup signal handlers */
985 CatchSignal(SIGINT, termination_handler); /* Exit on these sigs */
986 CatchSignal(SIGQUIT, termination_handler);
987 CatchSignal(SIGTERM, termination_handler);
988 CatchSignal(SIGCHLD, sigchld_handler);
990 CatchSignal(SIGPIPE, SIG_IGN); /* Ignore sigpipe */
992 CatchSignal(SIGUSR2, sigusr2_handler); /* Debugging sigs */
993 CatchSignal(SIGHUP, sighup_handler);
998 pidfile_create("winbindd");
1002 * If we're interactive we want to set our own process group for
1003 * signal management.
1006 setpgid( (pid_t)0, (pid_t)0);
1009 /* Initialise messaging system */
1011 if (!message_init()) {
1012 DEBUG(0, ("unable to initialise messaging system\n"));
1016 /* React on 'smbcontrol winbindd reload-config' in the same way
1017 as to SIGHUP signal */
1018 message_register(MSG_SMB_CONF_UPDATED, msg_reload_services);
1019 message_register(MSG_SHUTDOWN, msg_shutdown);
1021 poptFreeContext(pc);
1027 /* Loop waiting for requests */
1032 trustdom_cache_shutdown();