*/
#include "includes.h"
+#include "popt_common.h"
#include "smbd/globals.h"
#include "librpc/gen_ndr/messaging.h"
#include "registry.h"
#include "libcli/auth/schannel.h"
+#include "secrets.h"
static_decl_rpc;
DEBUG(10,("smb_conf_updated: Got message saying smb.conf was "
"updated. Reloading.\n"));
change_to_root_user();
- reload_services(False);
+ reload_services(msg, False);
}
}
if (s->parent->interactive) {
- smbd_process();
+ smbd_process(smbd_server_conn);
exit_server_cleanly("end of interactive mode");
return;
}
s = NULL;
status = reinit_after_fork(smbd_messaging_context(),
- smbd_event_context(), true);
+ smbd_event_context(), procid_self(),
+ true);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,
NT_STATUS_TOO_MANY_OPENED_FILES)) {
}
smbd_setup_sig_term_handler();
- smbd_setup_sig_hup_handler();
+ smbd_setup_sig_hup_handler(server_event_context(),
+ server_messaging_context());
if (!serverid_register(procid_self(),
FLAG_MSG_GENERAL|FLAG_MSG_SMBD
"serverid.tdb");
}
- smbd_process();
+ smbd_process(smbd_server_conn);
exit:
exit_server_cleanly("end of child");
return;
- } else if (pid < 0) {
+ }
+
+ if (pid < 0) {
DEBUG(0,("smbd_accept_connection: sys_fork() failed: %s\n",
strerror(errno)));
}
#ifdef CLUSTER_SUPPORT
if (lp_clustering()) {
- ctdbd_register_reconfigure(messaging_ctdbd_connection());
+ ctdbd_register_reconfigure(
+ messaging_ctdbd_connection(procid_self()));
}
#endif
};
struct smbd_parent_context *parent = NULL;
TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
+ NTSTATUS status;
+ uint64_t unique_id;
+
+ /* Initialize the event context, it will panic on error */
+ smbd_event_context();
smbd_init_globals();
setluid(0);
#endif
- sec_init();
-
set_remote_machine_name("smbd", False);
if (interactive && (DEBUGLEVEL >= 9)) {
client problems at a later date. (tridge) */
generate_random_buffer(NULL, 0);
+ /* get initial effective uid and gid */
+ sec_init();
+
/* make absolutely sure we run as root - to handle cases where people
are crazy enough to have it setuid */
-
gain_root_privilege();
gain_root_group_privilege();
so set our umask to 0 */
umask(0);
- init_sec_ctx();
-
reopen_logs();
DEBUG(0,("smbd version %s started.\n", samba_version_string()));
exit(1);
}
+ /* Init the security context and global current_user */
+ init_sec_ctx();
+
if (smbd_messaging_context() == NULL)
exit(1);
- if (!reload_services(False))
+ if (!reload_services(smbd_messaging_context(), False))
return(-1);
init_structs();
become_daemon(Fork, no_process_group, log_stdout);
}
+ generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id));
+ set_my_unique_id(unique_id);
+
#if HAVE_SETPGID
/*
* If we're interactive we want to set our own process group for
if (is_daemon)
pidfile_create("smbd");
- if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(),
- smbd_event_context(), false))) {
+ status = reinit_after_fork(smbd_messaging_context(),
+ smbd_event_context(),
+ procid_self(), false);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
exit(1);
}
+ smbd_server_conn->msg_ctx = smbd_messaging_context();
+
smbd_setup_sig_term_handler();
- smbd_setup_sig_hup_handler();
+ smbd_setup_sig_hup_handler(smbd_event_context(),
+ smbd_server_conn->msg_ctx);
/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
if (is_daemon && !interactive
&& lp_parm_bool(-1, "smbd", "backgroundqueue", true)) {
- start_background_queue();
+ start_background_queue(smbd_event_context(),
+ smbd_messaging_context());
}
if (!is_daemon) {
/* Stop zombies */
smbd_setup_sig_chld_handler();
- smbd_process();
+ smbd_process(smbd_server_conn);
exit_server_cleanly(NULL);
return(0);