#include "locking/share_mode_lock.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
+#include "smbd/smbXsrv_open.h"
#include "registry/reg_init_full.h"
#include "libcli/auth/schannel.h"
#include "secrets.h"
#include "../lib/util/memcache.h"
#include "ctdbd_conn.h"
+#include "lib/util/util_process.h"
#include "util_cluster.h"
#include "printing/queue_process.h"
-#include "rpc_server/rpc_service_setup.h"
#include "rpc_server/rpc_config.h"
#include "passdb.h"
#include "auth.h"
#include "lib/util/sys_rw.h"
#include "cleanupdb.h"
#include "g_lock.h"
-#include "rpc_server/epmd.h"
-#include "rpc_server/lsasd.h"
-#include "rpc_server/fssd.h"
-#include "rpc_server/mdssd.h"
#include "lib/global_contexts.h"
+#include "source3/lib/substitute.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb_protocol.h"
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
- struct dcesrv_context *dce_ctx;
/* the list of listening sockets */
struct smbd_open_socket *sockets;
struct server_id server_id,
DATA_BLOB *data)
{
- struct tevent_context *ev_ctx =
- talloc_get_type_abort(private_data, struct tevent_context);
bool ok;
DEBUG(10,("smbd_parent_conf_updated: Got message saying smb.conf was "
"updated. Reloading.\n"));
change_to_root_user();
reload_services(NULL, NULL, false);
- printing_subsystem_update(ev_ctx, msg, false);
ok = reinit_guest_session_info(NULL);
if (!ok) {
messaging_send_to_children(msg, MSG_SMB_CONF_UPDATED, NULL);
}
-/*******************************************************************
- Delete a statcache entry.
- ********************************************************************/
-
-static void smb_stat_cache_delete(struct messaging_context *msg,
- void *private_data,
- uint32_t msg_tnype,
- struct server_id server_id,
- DATA_BLOB *data)
-{
- const char *name = (const char *)data->data;
- DEBUG(10,("smb_stat_cache_delete: delete name %s\n", name));
- stat_cache_delete(name);
-}
-
/****************************************************************************
Send a SIGTERM to our process group.
*****************************************************************************/
{
DBG_NOTICE("notifyd: Reloading services after SIGHUP\n");
reload_services(NULL, NULL, false);
+ reopen_logs();
}
static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive,
{
struct tevent_context *ev = messaging_tevent_context(msg);
struct tevent_req *req;
+ struct tevent_signal *se = NULL;
pid_t pid;
NTSTATUS status;
bool ok;
- struct tevent_signal *se;
if (interactive) {
req = notifyd_req(msg, ev);
return true;
}
- status = smbd_reinit_after_fork(msg, ev, true, "smbd-notifyd");
+ status = smbd_reinit_after_fork(msg, ev, true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("%s: reinit_after_fork failed: %s\n",
__func__, nt_errstr(status)));
exit(1);
}
+ process_set_title("smbd-notifyd", "notifyd");
+
reopen_logs();
/* Set up sighup handler for notifyd */
}
}
+static void cleanupd_sig_hup_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *pvt)
+{
+ DBG_NOTICE("cleanupd: Reloading services after SIGHUP\n");
+ reopen_logs();
+}
+
static void cleanupd_stopped(struct tevent_req *req);
static bool cleanupd_init(struct messaging_context *msg, bool interactive,
{
struct tevent_context *ev = messaging_tevent_context(msg);
struct server_id parent_id = messaging_server_id(msg);
+ struct tevent_signal *se = NULL;
struct tevent_req *req;
pid_t pid;
NTSTATUS status;
close(up_pipe[0]);
- status = smbd_reinit_after_fork(msg, ev, true, "cleanupd");
+ status = smbd_reinit_after_fork(msg, ev, true);
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("reinit_after_fork failed: %s\n",
nt_errstr(status));
exit(1);
}
+ process_set_title("smbd-cleanupd", "cleanupd");
+
+ se = tevent_add_signal(ev,
+ ev,
+ SIGHUP,
+ 0,
+ cleanupd_sig_hup_handler,
+ NULL);
+ if (se == NULL) {
+ DBG_ERR("Could not add SIGHUP handler\n");
+ exit(1);
+ }
+
req = smbd_cleanupd_send(msg, ev, msg, parent_id.pid);
if (req == NULL) {
DBG_WARNING("smbd_cleanupd_send failed\n");
struct smbd_open_socket *s = talloc_get_type_abort(private_data,
struct smbd_open_socket);
struct messaging_context *msg_ctx = s->parent->msg_ctx;
- struct dcesrv_context *dce_ctx = s->parent->dce_ctx;
struct sockaddr_storage addr;
socklen_t in_addrlen = sizeof(addr);
int fd;
smb_set_close_on_exec(fd);
if (s->parent->interactive) {
- reinit_after_fork(msg_ctx, ev, true, NULL);
- smbd_process(ev, msg_ctx, dce_ctx, fd, true);
+ reinit_after_fork(msg_ctx, ev, true);
+ smbd_process(ev, msg_ctx, fd, true);
exit_server_cleanly("end of interactive mode");
return;
}
pid = fork();
if (pid == 0) {
+ char addrstr[INET6_ADDRSTRLEN];
NTSTATUS status = NT_STATUS_OK;
/*
* them, counting worker smbds. */
CatchChild();
- status = smbd_reinit_after_fork(msg_ctx, ev, true, NULL);
+ status = smbd_reinit_after_fork(msg_ctx, ev, true);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,
NT_STATUS_TOO_MANY_OPENED_FILES)) {
smb_panic("reinit_after_fork() failed");
}
- smbd_process(ev, msg_ctx, dce_ctx, fd, false);
+ print_sockaddr(addrstr, sizeof(addrstr), &addr);
+ process_set_title("smbd[%s]", "client [%s]", addrstr);
+
+ smbd_process(ev, msg_ctx, fd, false);
exit:
exit_server_cleanly("end of child");
return;
messaging_register(msg_ctx, NULL, MSG_SHUTDOWN, msg_exit_server);
messaging_register(msg_ctx, ev_ctx, MSG_SMB_CONF_UPDATED,
smbd_parent_conf_updated);
- messaging_register(msg_ctx, NULL, MSG_SMB_STAT_CACHE_DELETE,
- smb_stat_cache_delete);
messaging_register(msg_ctx, NULL, MSG_DEBUG, smbd_msg_debug);
messaging_register(msg_ctx, NULL, MSG_SMB_FORCE_TDIS,
smb_parent_send_to_children);
void *siginfo,
void *private_data)
{
- struct smbd_parent_context *parent =
- talloc_get_type_abort(private_data,
- struct smbd_parent_context);
-
change_to_root_user();
DEBUG(1,("parent: Reloading services after SIGHUP\n"));
reload_services(NULL, NULL, false);
-
- printing_subsystem_update(parent->ev_ctx, parent->msg_ctx, true);
}
struct smbd_claim_version_state {
static void smbd_claim_version_parser(struct server_id exclusive,
size_t num_shared,
- struct server_id *shared,
+ const struct server_id *shared,
const uint8_t *data,
size_t datalen,
void *private_data)
return NT_STATUS_UNSUCCESSFUL;
}
- status = g_lock_lock(
- ctx, key, G_LOCK_READ, (struct timeval) { .tv_sec = 60 });
+ status = g_lock_lock(ctx,
+ key,
+ G_LOCK_READ,
+ (struct timeval) { .tv_sec = 60 },
+ NULL,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("g_lock_lock(G_LOCK_READ) failed: %s\n",
nt_errstr(status));
return NT_STATUS_OK;
}
- status = g_lock_lock(
- ctx, key, G_LOCK_UPGRADE, (struct timeval) { .tv_sec = 60 });
+ status = g_lock_lock(ctx,
+ key,
+ G_LOCK_UPGRADE,
+ (struct timeval) { .tv_sec = 60 },
+ NULL,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("g_lock_lock(G_LOCK_WRITE) failed: %s\n",
nt_errstr(status));
return status;
}
- status = g_lock_lock(
- ctx, key, G_LOCK_DOWNGRADE, (struct timeval) { .tv_sec = 60 });
+ status = g_lock_lock(ctx,
+ key,
+ G_LOCK_DOWNGRADE,
+ (struct timeval) { .tv_sec = 60 },
+ NULL,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("g_lock_lock(G_LOCK_READ) failed: %s\n",
nt_errstr(status));
char *profile_level = NULL;
int opt;
poptContext pc;
- bool print_build_options = False;
- bool serving_printers = false;
struct server_id main_server_id = {0};
struct poptOption long_options[] = {
POPT_AUTOHELP
NTSTATUS status;
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
- struct dcesrv_context *dce_ctx = NULL;
struct server_id server_id;
struct tevent_signal *se;
int profiling_level;
loadparm_s3_global_substitution();
static const struct smbd_shim smbd_shim_fns =
{
- .send_stat_cache_delete_message = smbd_send_stat_cache_delete_message,
.change_to_root_user = smbd_change_to_root_user,
.become_authenticated_pipe_user = smbd_become_authenticated_pipe_user,
.unbecome_authenticated_pipe_user = smbd_unbecome_authenticated_pipe_user,
};
bool ok;
+ setproctitle_init(argc, discard_const(argv), environ);
+
/*
* Do this before any other talloc operation
*/
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case 'b':
- print_build_options = True;
+ build_options(true); /* Display output to screen as well as debug */
+ exit(0);
break;
default:
d_fprintf(stderr, "\nInvalid option %s: %s\n\n",
log_stdout = True;
}
- if (print_build_options) {
- build_options(True); /* Display output to screen as well as debug */
- exit(0);
- }
-
#ifdef HAVE_SETLUID
/* needed for SecureWare on SCO */
setluid(0);
DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n",
(int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid()));
- /* Output the build options to the debug log */
+ /* Output the build options to the debug log */
build_options(False);
if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4) {
exit(1);
}
- dce_ctx = global_dcesrv_context();
- if (dce_ctx == NULL) {
- exit(1);
- }
-
/*
* Reloading of the printers will not work here as we don't have a
* server info and rpc services set up. It will be called later.
if (cmdline_daemon_cfg->daemon)
pidfile_create(lp_pid_directory(), "smbd");
- status = reinit_after_fork(msg_ctx, ev_ctx, false, NULL);
+ status = reinit_after_fork(msg_ctx, ev_ctx, false);
if (!NT_STATUS_IS_OK(status)) {
exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
}
parent->interactive = cmdline_daemon_cfg->interactive;
parent->ev_ctx = ev_ctx;
parent->msg_ctx = msg_ctx;
- parent->dce_ctx = dce_ctx;
am_parent = parent;
se = tevent_add_signal(parent->ev_ctx,
exit_daemon("smbd can not open secrets.tdb", EACCES);
}
- if (lp_server_role() == ROLE_DOMAIN_BDC || lp_server_role() == ROLE_DOMAIN_PDC) {
+ if (lp_server_role() == ROLE_DOMAIN_BDC || lp_server_role() == ROLE_DOMAIN_PDC || lp_server_role() == ROLE_IPA_DC) {
struct loadparm_context *lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers());
if (!open_schannel_session_store(NULL, lp_ctx)) {
exit_daemon("ERROR: Samba cannot open schannel store for secured NETLOGON operations.", EACCES);
return -1;
}
- status = dcesrv_init(ev_ctx, ev_ctx, msg_ctx, dce_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_ERR("Failed to setup RPC server: %s\n", nt_errstr(status));
- exit_daemon("Samba cannot setup ep pipe", EACCES);
- }
-
if (!cmdline_daemon_cfg->interactive) {
daemon_ready("smbd");
}
- serving_printers = (!lp__disable_spoolss() &&
- (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED));
-
- /* only start other daemons if we are running as a daemon
- * -- bad things will happen if smbd is launched via inetd
- * and we fork a copy of ourselves here */
- if (cmdline_daemon_cfg->daemon && !cmdline_daemon_cfg->interactive) {
-
- if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) {
- start_epmd(ev_ctx, msg_ctx, dce_ctx);
- }
-
- if (rpc_lsasd_daemon() == RPC_DAEMON_FORK) {
- start_lsasd(ev_ctx, msg_ctx, dce_ctx);
- }
-
- if (rpc_fss_daemon() == RPC_DAEMON_FORK) {
- start_fssd(ev_ctx, msg_ctx, dce_ctx);
- }
-
- if (serving_printers) {
- bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true);
- ok = printing_subsystem_init(ev_ctx,
- msg_ctx,
- dce_ctx,
- true,
- bgq);
- if (!ok) {
- exit_daemon("Samba failed to init printing subsystem", EACCES);
- }
- }
-
-#ifdef WITH_SPOTLIGHT
- if ((rpc_mdssvc_mode() == RPC_SERVICE_MODE_EXTERNAL) &&
- (rpc_mdssd_daemon() == RPC_DAEMON_FORK)) {
- start_mdssd(ev_ctx, msg_ctx, dce_ctx);
- }
-#endif
- } else if (serving_printers) {
- ok = printing_subsystem_init(ev_ctx,
- msg_ctx,
- dce_ctx,
- false,
- false);
- if (!ok) {
- exit(1);
- }
- }
-
if (!cmdline_daemon_cfg->daemon) {
int ret, sock;
/* Stop zombies */
smbd_setup_sig_chld_handler(parent);
- smbd_process(ev_ctx, msg_ctx, dce_ctx, sock, true);
+ smbd_process(ev_ctx, msg_ctx, sock, true);
exit_server_cleanly(NULL);
return(0);
if (!open_sockets_smbd(parent, ev_ctx, msg_ctx, ports))
exit_server("open_sockets_smbd() failed");
- /* do a printer update now that all messaging has been set up,
- * before we allow clients to start connecting */
- if (!lp__disable_spoolss() &&
- (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) {
- printing_subsystem_update(ev_ctx, msg_ctx, false);
- }
-
TALLOC_FREE(frame);
/* make sure we always have a valid stackframe */
frame = talloc_stackframe();
*/
struct stat st;
if (fstat(0, &st) != 0) {
- return false;
+ return 1;
}
if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
tevent_add_fd(ev_ctx,