kill_async_dns_child();
gencache_stabilize();
- serverid_deregister(messaging_server_id(msg));
pidfile_unlink(lp_pid_directory(), "nmbd");
set_remote_machine_name("nmbd", False);
if ( lp_loaded() ) {
- char *fname = lp_configfile(talloc_tos());
+ char *fname = lp_next_configfile(talloc_tos());
if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
set_dyn_CONFIGFILE(fname);
test = False;
reload_nmbd_services( True );
}
+ reopen_logs();
+
return(ret);
}
setup_logging(argv[0], DEBUG_DEFAULT_STDOUT);
- load_case_tables();
+ smb_init_locale();
global_nmb_port = NMB_PORT;
BlockSignals(True, SIGUSR2);
#endif
+ /* Ignore children - no zombies. */
+ CatchChild();
+
if ( opt_interactive ) {
Fork = False;
log_stdout = True;
exit(1);
}
+ reopen_logs();
+
if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC
&& !lp_parm_bool(-1, "server role check", "inhibit", false)) {
/* TODO: when we have a merged set of defaults for
set_samba_nb_type();
if (!is_daemon && !is_a_socket(0)) {
- DEBUG(0,("standard input is not a socket, assuming -D option\n"));
+ DEBUG(3, ("standard input is not a socket, assuming -D option\n"));
is_daemon = True;
}
if (is_daemon && !opt_interactive) {
- DEBUG( 2, ( "Becoming a daemon.\n" ) );
+ DEBUG(3, ("Becoming a daemon.\n"));
become_daemon(Fork, no_process_group, log_stdout);
}
}
#endif
- ok = directory_create_or_exist(lp_lock_directory(), geteuid(), 0755);
+ ok = directory_create_or_exist(lp_lock_directory(), 0755);
if (!ok) {
- DEBUG(0, ("Failed to create directory %s for lock files - %s\n",
- lp_lock_directory(), strerror(errno)));
- exit(1);
+ exit_daemon("Failed to create directory for lock files, check 'lock directory'", errno);
}
- ok = directory_create_or_exist(lp_pid_directory(), geteuid(), 0755);
+ ok = directory_create_or_exist(lp_pid_directory(), 0755);
if (!ok) {
- DEBUG(0, ("Failed to create directory %s for pid files - %s\n",
- lp_pid_directory(), strerror(errno)));
- exit(1);
+ exit_daemon("Failed to create directory for pid files, check 'pid directory'", errno);
}
pidfile_create(lp_pid_directory(), "nmbd");
- status = reinit_after_fork(msg, nmbd_event_context(),
- false);
+ status = reinit_after_fork(msg, nmbd_event_context(), false, NULL);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("reinit_after_fork() failed\n"));
- exit(1);
+ exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
}
/*
*/
status = init_before_fork();
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("init_before_fork failed: %s\n", nt_errstr(status)));
- exit(1);
+ exit_daemon(nt_errstr(status), map_errno_from_nt_status(status));
}
if (!nmbd_setup_sig_term_handler(msg))
- exit(1);
+ exit_daemon("NMBD failed to setup signal handler", EINVAL);
if (!nmbd_setup_stdin_handler(msg, !Fork))
- exit(1);
+ exit_daemon("NMBD failed to setup stdin handler", EINVAL);
if (!nmbd_setup_sig_hup_handler(msg))
- exit(1);
-
- /* get broadcast messages */
+ exit_daemon("NMBD failed to setup SIGHUP handler", EINVAL);
- if (!serverid_register(messaging_server_id(msg),
- FLAG_MSG_GENERAL |
- FLAG_MSG_NMBD |
- FLAG_MSG_DBWRAP)) {
- DEBUG(1, ("Could not register myself in serverid.tdb\n"));
+ if (!messaging_parent_dgm_cleanup_init(msg)) {
exit(1);
}
/* Create an nmbd subnet record for each of the above. */
if( False == create_subnets() ) {
- DEBUG(0,("ERROR: Failed when creating subnet lists. Exiting.\n"));
kill_async_dns_child();
- exit(1);
+ exit_daemon("NMBD failed when creating subnet lists", EACCES);
}
/* Load in any static local names. */
/* If we are acting as a WINS server, initialise data structures. */
if( !initialise_wins() ) {
- DEBUG( 0, ( "nmbd: Failed when initialising WINS server.\n" ) );
kill_async_dns_child();
- exit(1);
+ exit_daemon( "NMBD failed when initialising WINS server.", EACCES);
}
/*
*/
if( False == register_my_workgroup_and_names() ) {
- DEBUG(0,("ERROR: Failed when creating my my workgroup. Exiting.\n"));
kill_async_dns_child();
- exit(1);
+ exit_daemon( "NMBD failed when creating my workgroup.", EACCES);
}
if (!initialize_nmbd_proxy_logon()) {
- DEBUG(0,("ERROR: Failed setup nmbd_proxy_logon.\n"));
kill_async_dns_child();
- exit(1);
+ exit_daemon( "NMBD failed to setup nmbd_proxy_logon.", EACCES);
}
if (!nmbd_init_packet_server()) {
kill_async_dns_child();
- exit(1);
- }
+ exit_daemon( "NMBD failed to setup packet server.", EACCES);
+ }
+
+ if (is_daemon && !opt_interactive) {
+ daemon_ready("nmbd");
+ }
TALLOC_FREE(frame);
process(msg);