2 Unix SMB/CIFS implementation.
3 Main SMB server routines
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Martin Pool 2002
6 Copyright (C) Jelmer Vernooij 2002-2003
7 Copyright (C) James Peach 2007
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 static int am_parent = 1;
30 /* the last message the was processed */
31 int last_message = -1;
33 /* a useful macro to debug the last message processed */
34 #define LAST_MESSAGE() smb_fn_name(last_message)
36 extern struct auth_context *negprot_global_auth_context;
37 extern pstring user_socket_options;
38 extern SIG_ATOMIC_T got_sig_term;
39 extern SIG_ATOMIC_T reload_after_sighup;
40 static SIG_ATOMIC_T got_sig_cld;
43 extern int dcelogin_atmost_once;
46 /* really we should have a top level context structure that has the
47 client file descriptor as an element. That would require a major rewrite :(
49 the following 2 functions are an alternative - they make the file
50 descriptor private to smbd
52 static int server_fd = -1;
54 int smbd_server_fd(void)
59 static void smbd_set_server_fd(int fd)
65 struct event_context *smbd_event_context(void)
67 static struct event_context *ctx;
69 if (!ctx && !(ctx = event_context_init(NULL))) {
70 smb_panic("Could not init smbd event context\n");
75 struct messaging_context *smbd_messaging_context(void)
77 static struct messaging_context *ctx;
79 if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
80 smbd_event_context()))) {
81 smb_panic("Could not init smbd messaging context\n");
86 /*******************************************************************
87 What to do when smb.conf is updated.
88 ********************************************************************/
90 static void smb_conf_updated(struct messaging_context *msg,
93 struct server_id server_id,
96 DEBUG(10,("smb_conf_updated: Got message saying smb.conf was "
97 "updated. Reloading.\n"));
98 reload_services(False);
102 /*******************************************************************
103 Delete a statcache entry.
104 ********************************************************************/
106 static void smb_stat_cache_delete(struct messaging_context *msg,
109 struct server_id server_id,
112 const char *name = (const char *)data->data;
113 DEBUG(10,("smb_stat_cache_delete: delete name %s\n", name));
114 stat_cache_delete(name);
117 /****************************************************************************
119 ****************************************************************************/
121 static void sig_term(void)
124 sys_select_signal(SIGTERM);
127 /****************************************************************************
129 ****************************************************************************/
131 static void sig_hup(int sig)
133 reload_after_sighup = 1;
134 sys_select_signal(SIGHUP);
137 /****************************************************************************
139 ****************************************************************************/
140 static void sig_cld(int sig)
143 sys_select_signal(SIGCLD);
146 /****************************************************************************
147 Send a SIGTERM to our process group.
148 *****************************************************************************/
150 static void killkids(void)
152 if(am_parent) kill(0,SIGTERM);
155 /****************************************************************************
156 Process a sam sync message - not sure whether to do this here or
158 ****************************************************************************/
160 static void msg_sam_sync(struct messaging_context *msg,
163 struct server_id server_id,
166 DEBUG(10, ("** sam sync message received, ignoring\n"));
169 /****************************************************************************
170 Process a sam sync replicate message - not sure whether to do this here or
172 ****************************************************************************/
174 static void msg_sam_repl(struct messaging_context *msg,
177 struct server_id server_id,
182 if (data->length != sizeof(low_serial))
185 low_serial = *((uint32 *)data->data);
187 DEBUG(3, ("received sam replication message, serial = 0x%04x\n",
191 /****************************************************************************
192 Open the socket communication - inetd.
193 ****************************************************************************/
195 static BOOL open_sockets_inetd(void)
197 /* Started from inetd. fd 0 is the socket. */
198 /* We will abort gracefully when the client or remote system
200 smbd_set_server_fd(dup(0));
202 /* close our standard file descriptors */
203 close_low_fds(False); /* Don't close stderr */
205 set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
206 set_socket_options(smbd_server_fd(), user_socket_options);
211 static void msg_exit_server(struct messaging_context *msg,
214 struct server_id server_id,
217 DEBUG(3, ("got a SHUTDOWN message\n"));
218 exit_server_cleanly(NULL);
222 static void msg_inject_fault(struct messaging_context *msg,
225 struct server_id src,
230 if (data->length != sizeof(sig)) {
232 DEBUG(0, ("Process %s sent bogus signal injection request\n",
233 procid_str_static(&src)));
237 sig = *(int *)data->data;
239 exit_server("internal error injected");
244 DEBUG(0, ("Process %s requested injection of signal %d (%s)\n",
245 procid_str_static(&src), sig, strsignal(sig)));
247 DEBUG(0, ("Process %s requested injection of signal %d\n",
248 procid_str_static(&src), sig));
251 kill(sys_getpid(), sig);
253 #endif /* DEVELOPER */
256 struct child_pid *prev, *next;
260 static struct child_pid *children;
261 static int num_children;
263 static void add_child_pid(pid_t pid)
265 struct child_pid *child;
267 if (lp_max_smbd_processes() == 0) {
268 /* Don't bother with the child list if we don't care anyway */
272 child = SMB_MALLOC_P(struct child_pid);
274 DEBUG(0, ("Could not add child struct -- malloc failed\n"));
278 DLIST_ADD(children, child);
282 static void remove_child_pid(pid_t pid)
284 struct child_pid *child;
286 if (lp_max_smbd_processes() == 0) {
287 /* Don't bother with the child list if we don't care anyway */
291 for (child = children; child != NULL; child = child->next) {
292 if (child->pid == pid) {
293 struct child_pid *tmp = child;
294 DLIST_REMOVE(children, child);
301 DEBUG(0, ("Could not find child %d -- ignoring\n", (int)pid));
304 /****************************************************************************
305 Have we reached the process limit ?
306 ****************************************************************************/
308 static BOOL allowable_number_of_smbd_processes(void)
310 int max_processes = lp_max_smbd_processes();
315 return num_children < max_processes;
318 /****************************************************************************
319 Open the socket communication.
320 ****************************************************************************/
322 static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_ports)
325 int fd_listenset[FD_SETSIZE];
330 struct timeval idle_timeout = timeval_zero();
332 if (server_mode == SERVER_MODE_INETD) {
333 return open_sockets_inetd();
338 static int atexit_set;
339 if(atexit_set == 0) {
347 CatchSignal(SIGCLD, sig_cld);
349 FD_ZERO(&listen_set);
351 /* At this point, it doesn't matter what daemon mode we are in, we
352 * need some sockets to listen on.
354 num_sockets = smbd_sockinit(smb_ports, fd_listenset, &idle_timeout);
355 if (num_sockets == 0) {
359 for (i = 0; i < num_sockets; ++i) {
360 FD_SET(fd_listenset[i], &listen_set);
361 maxfd = MAX(maxfd, fd_listenset[i]);
364 /* Listen to messages */
366 messaging_register(smbd_messaging_context(), NULL,
367 MSG_SMB_SAM_SYNC, msg_sam_sync);
368 messaging_register(smbd_messaging_context(), NULL,
369 MSG_SMB_SAM_REPL, msg_sam_repl);
370 messaging_register(smbd_messaging_context(), NULL,
371 MSG_SHUTDOWN, msg_exit_server);
372 messaging_register(smbd_messaging_context(), NULL,
373 MSG_SMB_FILE_RENAME, msg_file_was_renamed);
374 messaging_register(smbd_messaging_context(), NULL,
375 MSG_SMB_CONF_UPDATED, smb_conf_updated);
376 messaging_register(smbd_messaging_context(), NULL,
377 MSG_SMB_STAT_CACHE_DELETE, smb_stat_cache_delete);
380 messaging_register(smbd_messaging_context(), NULL,
381 MSG_SMB_INJECT_FAULT, msg_inject_fault);
384 /* now accept incoming connections - forking a new process
385 for each incoming connection */
386 DEBUG(2,("waiting for a connection\n"));
391 /* Free up temporary memory from the main smbd. */
394 /* Ensure we respond to PING and DEBUG messages from the main smbd. */
395 message_dispatch(smbd_messaging_context());
401 while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) {
402 remove_child_pid(pid);
406 memcpy((char *)&lfds, (char *)&listen_set,
409 num = sys_select(maxfd+1,&lfds,NULL,NULL,
410 timeval_is_zero(&idle_timeout) ?
411 NULL : &idle_timeout);
413 if (num == -1 && errno == EINTR) {
415 exit_server_cleanly(NULL);
418 /* check for sighup processing */
419 if (reload_after_sighup) {
420 change_to_root_user();
421 DEBUG(1,("Reloading services after SIGHUP\n"));
422 reload_services(False);
423 reload_after_sighup = 0;
429 /* If the idle timeout fired and we don't have any connected
430 * users, exit gracefully. We should be running under a process
431 * controller that will restart us if necessry.
433 if (num == 0 && count_all_current_connections() == 0) {
434 exit_server_cleanly("idle timeout");
437 /* check if we need to reload services */
438 check_reload(time(NULL));
440 /* Find the sockets that are read-ready -
442 for( ; num > 0; num--) {
443 struct sockaddr addr;
444 socklen_t in_addrlen = sizeof(addr);
448 for(i = 0; i < num_sockets; i++) {
449 if(FD_ISSET(fd_listenset[i],&lfds)) {
451 /* Clear this so we don't look
453 FD_CLR(fd_listenset[i],&lfds);
458 smbd_set_server_fd(accept(s,&addr,&in_addrlen));
460 if (smbd_server_fd() == -1 && errno == EINTR)
463 if (smbd_server_fd() == -1) {
464 DEBUG(0,("open_sockets_smbd: accept: %s\n",
469 /* Ensure child is set to blocking mode */
470 set_blocking(smbd_server_fd(),True);
472 /* In interactive mode, return with a connected socket.
473 * Foreground and daemon modes should fork worker
476 if (server_mode == SERVER_MODE_INTERACTIVE) {
480 if (allowable_number_of_smbd_processes() &&
481 smbd_server_fd() != -1 &&
482 ((child = sys_fork())==0)) {
485 /* Stop zombies, the parent explicitly handles
486 * them, counting worker smbds. */
489 /* close the listening socket(s) */
490 for(i = 0; i < num_sockets; i++)
491 close(fd_listenset[i]);
493 /* close our standard file
495 close_low_fds(False);
498 set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
499 set_socket_options(smbd_server_fd(),user_socket_options);
501 /* this is needed so that we get decent entries
502 in smbstatus for port 445 connects */
503 set_remote_machine_name(get_peer_addr(smbd_server_fd()),
506 /* Reset the state of the random
507 * number generation system, so
508 * children do not get the same random
509 * numbers as each other */
511 set_need_random_reseed();
512 /* tdb needs special fork handling - remove
513 * CLEAR_IF_FIRST flags */
514 if (tdb_reopen_all(1) == -1) {
515 DEBUG(0,("tdb_reopen_all failed.\n"));
516 smb_panic("tdb_reopen_all failed.");
521 /* The parent doesn't need this socket */
522 close(smbd_server_fd());
524 /* Sun May 6 18:56:14 2001 ackley@cs.unm.edu:
525 Clear the closed fd info out of server_fd --
526 and more importantly, out of client_fd in
527 util_sock.c, to avoid a possible
528 getpeername failure if we reopen the logs
529 and use %I in the filename.
532 smbd_set_server_fd(-1);
535 add_child_pid(child);
538 /* Force parent to check log size after
539 * spawning child. Fix from
540 * klausr@ITAP.Physik.Uni-Stuttgart.De. The
541 * parent smbd will log to logserver.smb. It
542 * writes only two messages for each child
543 * started/finished. But each child writes,
544 * say, 50 messages also in logserver.smb,
545 * begining with the debug_count of the
546 * parent, before the child opens its own log
547 * file logserver.client. In a worst case
548 * scenario the size of logserver.smb would be
549 * checked after about 50*50=2500 messages
552 force_check_log_size();
557 /* NOTREACHED return True; */
560 /****************************************************************************
562 **************************************************************************/
563 void reload_printers(void)
566 int n_services = lp_numservices();
567 int pnum = lp_servicenumber(PRINTERS_NAME);
572 /* remove stale printers */
573 for (snum = 0; snum < n_services; snum++) {
574 /* avoid removing PRINTERS_NAME or non-autoloaded printers */
575 if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
576 lp_autoloaded(snum)))
579 pname = lp_printername(snum);
580 if (!pcap_printername_ok(pname)) {
581 DEBUG(3, ("removing stale printer %s\n", pname));
583 if (is_printer_published(NULL, snum, NULL))
584 nt_printer_publish(NULL, snum, SPOOL_DS_UNPUBLISH);
585 del_a_printer(pname);
586 lp_killservice(snum);
593 /****************************************************************************
594 Reload the services file.
595 **************************************************************************/
597 BOOL reload_services(BOOL test)
603 pstrcpy(fname,lp_configfile());
604 if (file_exist(fname, NULL) &&
605 !strcsequal(fname, dyn_CONFIGFILE)) {
606 pstrcpy(dyn_CONFIGFILE, fname);
613 if (test && !lp_file_list_changed())
616 lp_killunused(conn_snum_used);
618 ret = lp_load(dyn_CONFIGFILE, False, False, True, True);
622 /* perhaps the config filename is now set */
624 reload_services(True);
630 if (smbd_server_fd() != -1) {
631 set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
632 set_socket_options(smbd_server_fd(), user_socket_options);
635 mangle_reset_cache();
638 /* this forces service parameters to be flushed */
639 set_current_service(NULL,0,True);
644 /****************************************************************************
646 ****************************************************************************/
648 /* Reasons for shutting down a server process. */
649 enum server_exit_reason { SERVER_EXIT_NORMAL, SERVER_EXIT_ABNORMAL };
651 static void exit_server_common(enum server_exit_reason how,
652 const char *const reason) NORETURN_ATTRIBUTE;
654 static void exit_server_common(enum server_exit_reason how,
655 const char *const reason)
657 static int firsttime=1;
663 change_to_root_user();
665 if (negprot_global_auth_context) {
666 (negprot_global_auth_context->free)(&negprot_global_auth_context);
671 invalidate_all_vuids();
673 /* 3 second timeout. */
674 print_notify_send_messages(smbd_messaging_context(), 3);
676 /* delete our entry in the connections database. */
677 yield_connection(NULL,"");
679 respond_to_all_remaining_local_messages();
682 if (dcelogin_atmost_once) {
690 server_encryption_shutdown();
692 if (how != SERVER_EXIT_NORMAL) {
693 int oldlevel = DEBUGLEVEL;
694 char *last_inbuf = get_InBuffer();
699 DEBUG(0,("Abnormal server exit: %s\n",
700 reason ? reason : "no explanation provided"));
705 DEBUG(0,("Last message was %s\n", LAST_MESSAGE()));
706 show_msg(last_inbuf);
709 DEBUGLEVEL = oldlevel;
713 DEBUG(3,("Server exit (%s)\n",
714 (reason ? reason : "normal exit")));
720 void exit_server(const char *const explanation)
722 exit_server_common(SERVER_EXIT_ABNORMAL, explanation);
725 void exit_server_cleanly(const char *const explanation)
727 exit_server_common(SERVER_EXIT_NORMAL, explanation);
730 void exit_server_fault(void)
732 exit_server("critical server fault");
735 /****************************************************************************
736 Initialise connect, service and file structs.
737 ****************************************************************************/
739 static BOOL init_structs(void )
742 * Set the machine NETBIOS name if not already
743 * set from the config file.
764 * Send keepalive packets to our client
766 static BOOL keepalive_fn(const struct timeval *now, void *private_data)
768 if (!send_keepalive(smbd_server_fd())) {
769 DEBUG( 2, ( "Keepalive failed - exiting.\n" ) );
776 * Do the recurring check if we're idle
778 static BOOL deadtime_fn(const struct timeval *now, void *private_data)
780 if ((conn_num_open() == 0)
781 || (conn_idle_all(now->tv_sec))) {
782 DEBUG( 2, ( "Closing idle connection\n" ) );
783 messaging_send(smbd_messaging_context(), procid_self(),
784 MSG_SHUTDOWN, &data_blob_null);
792 /****************************************************************************
794 ****************************************************************************/
796 /* Declare prototype for build_options() to avoid having to run it through
797 mkproto.h. Mixing $(builddir) and $(srcdir) source files in the current
798 prototype generation system is too complicated. */
800 extern void build_options(BOOL screen);
802 int main(int argc,const char *argv[])
804 /* shall I run as a daemon */
805 BOOL no_process_group = False;
806 BOOL log_stdout = False;
807 const char *ports = NULL;
808 const char *profile_level = NULL;
812 enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
814 struct poptOption long_options[] = {
816 {"daemon", 'D', POPT_ARG_VAL, &server_mode, SERVER_MODE_DAEMON,
817 "Become a daemon (default)" },
818 {"interactive", 'i', POPT_ARG_VAL, &server_mode, SERVER_MODE_INTERACTIVE,
819 "Run interactive (not a daemon)"},
820 {"foreground", 'F', POPT_ARG_VAL, &server_mode, SERVER_MODE_FOREGROUND,
821 "Run daemon in foreground (for daemontools, etc.)" },
822 {"no-process-group", '\0', POPT_ARG_VAL, &no_process_group, True,
823 "Don't create a new process group" },
824 {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
825 {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
826 {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
827 {"profiling-level", 'P', POPT_ARG_STRING, &profile_level, 0, "Set profiling level","PROFILE_LEVEL"},
829 POPT_COMMON_DYNCONFIG
837 #ifdef HAVE_SET_AUTH_PARAMETERS
838 set_auth_parameters(argc,argv);
841 pc = poptGetContext("smbd", argc, argv, long_options, 0);
843 while((opt = poptGetNextOpt(pc)) != -1) {
846 build_options(True); /* Display output to screen as well as debug */
855 /* needed for SecureWare on SCO */
861 set_remote_machine_name("smbd", False);
863 if (server_mode == SERVER_MODE_INTERACTIVE) {
865 if (DEBUGLEVEL >= 9) {
866 talloc_enable_leak_report();
870 if (log_stdout && server_mode == SERVER_MODE_DAEMON) {
871 DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n"));
875 setup_logging(argv[0],log_stdout);
877 /* we want to re-seed early to prevent time delays causing
878 client problems at a later date. (tridge) */
879 generate_random_buffer(NULL, 0);
881 /* make absolutely sure we run as root - to handle cases where people
882 are crazy enough to have it setuid */
884 gain_root_privilege();
885 gain_root_group_privilege();
887 fault_setup((void (*)(void *))exit_server_fault);
888 dump_core_setup("smbd");
890 CatchSignal(SIGTERM , SIGNAL_CAST sig_term);
891 CatchSignal(SIGHUP,SIGNAL_CAST sig_hup);
893 /* we are never interested in SIGPIPE */
894 BlockSignals(True,SIGPIPE);
897 /* we are never interested in SIGFPE */
898 BlockSignals(True,SIGFPE);
902 /* We are no longer interested in USR2 */
903 BlockSignals(True,SIGUSR2);
906 /* POSIX demands that signals are inherited. If the invoking process has
907 * these signals masked, we will have problems, as we won't recieve them. */
908 BlockSignals(False, SIGHUP);
909 BlockSignals(False, SIGUSR1);
910 BlockSignals(False, SIGTERM);
912 /* we want total control over the permissions on created files,
913 so set our umask to 0 */
920 DEBUG(0,( "smbd version %s started.\n", SAMBA_VERSION_STRING));
921 DEBUGADD( 0, ( "%s\n", COPYRIGHT_STARTUP_MESSAGE ) );
923 DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n",
924 (int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid()));
926 /* Output the build options to the debug log */
927 build_options(False);
929 if (sizeof(uint16) < 2 || sizeof(uint32) < 4) {
930 DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n"));
935 * Do this before reload_services.
938 if (!reload_services(False))
944 if (!profile_setup(smbd_messaging_context(), False)) {
945 DEBUG(0,("ERROR: failed to setup profiling\n"));
948 if (profile_level != NULL) {
949 int pl = atoi(profile_level);
950 struct server_id src;
952 DEBUG(1, ("setting profiling level: %s\n",profile_level));
954 set_profile_level(pl, src);
958 DEBUG(3,( "loaded services\n"));
960 if (is_a_socket(0)) {
961 if (server_mode == SERVER_MODE_DAEMON) {
962 DEBUG(0,("standard input is a socket, "
963 "assuming -F option\n"));
965 server_mode = SERVER_MODE_INETD;
968 if (server_mode == SERVER_MODE_DAEMON) {
969 DEBUG( 3, ( "Becoming a daemon.\n" ) );
970 become_daemon(True, no_process_group);
971 } else if (server_mode == SERVER_MODE_FOREGROUND) {
972 become_daemon(False, no_process_group);
977 * If we're interactive we want to set our own process group for
980 if (server_mode == SERVER_MODE_INTERACTIVE && !no_process_group) {
981 setpgid( (pid_t)0, (pid_t)0);
985 if (!directory_exist(lp_lockdir(), NULL))
986 mkdir(lp_lockdir(), 0755);
988 if (server_mode != SERVER_MODE_INETD &&
989 server_mode != SERVER_MODE_INTERACTIVE) {
990 pidfile_create("smbd");
993 /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
994 if (smbd_messaging_context() == NULL)
997 /* Initialise the password backed before the global_sam_sid
998 to ensure that we fetch from ldap before we make a domain sid up */
1000 if(!initialize_password_db(False, smbd_event_context()))
1003 if (!secrets_init()) {
1004 DEBUG(0, ("ERROR: smbd can not open secrets.tdb\n"));
1008 if(!get_global_sam_sid()) {
1009 DEBUG(0,("ERROR: Samba cannot create a SAM SID.\n"));
1013 if (!session_init())
1016 if (!connections_init(True))
1019 if (!locking_init(0))
1024 if (!init_registry())
1028 if (!init_svcctl_db())
1032 if (!print_backend_init(smbd_messaging_context()))
1035 if (!init_guest_info()) {
1036 DEBUG(0,("ERROR: failed to setup guest info.\n"));
1040 /* Setup the main smbd so that we can get messages. */
1041 /* don't worry about general printing messages here */
1043 claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD);
1045 /* only start the background queue daemon if we are
1046 running as a daemon -- bad things will happen if
1047 smbd is launched via inetd and we fork a copy of
1049 if (server_mode != SERVER_MODE_INETD &&
1050 server_mode != SERVER_MODE_INTERACTIVE) {
1051 start_background_queue();
1054 /* Always attempt to initialize DMAPI. We will only use it later if
1055 * lp_dmapi_support is set on the share, but we need a single global
1056 * session to work with.
1058 dmapi_init_session();
1060 if (!open_sockets_smbd(server_mode, ports)) {
1065 * everything after this point is run after the fork()
1072 /* Possibly reload the services file. Only worth doing in
1073 * daemon mode. In inetd mode, we know we only just loaded this.
1075 if (server_mode != SERVER_MODE_INETD &&
1076 server_mode != SERVER_MODE_INTERACTIVE) {
1077 reload_services(True);
1080 if (!init_account_policy()) {
1081 DEBUG(0,("Could not open account policy tdb.\n"));
1085 if (*lp_rootdir()) {
1086 if (sys_chroot(lp_rootdir()) == 0)
1087 DEBUG(2,("Changed root to %s\n", lp_rootdir()));
1091 if (!init_oplocks(smbd_messaging_context()))
1094 /* Setup aio signal handler. */
1095 initialize_async_io_handler();
1097 /* register our message handlers */
1098 messaging_register(smbd_messaging_context(), NULL,
1099 MSG_SMB_FORCE_TDIS, msg_force_tdis);
1101 if ((lp_keepalive() != 0)
1102 && !(event_add_idle(smbd_event_context(), NULL,
1103 timeval_set(lp_keepalive(), 0),
1104 "keepalive", keepalive_fn,
1106 DEBUG(0, ("Could not add keepalive event\n"));
1110 if (!(event_add_idle(smbd_event_context(), NULL,
1111 timeval_set(IDLE_CLOSED_TIMEOUT, 0),
1112 "deadtime", deadtime_fn, NULL))) {
1113 DEBUG(0, ("Could not add deadtime event\n"));
1119 namecache_shutdown();
1121 exit_server_cleanly(NULL);