#include "secrets.h"
#include "memcache.h"
#include "ctdbd_conn.h"
-#include "printing/printer_list.h"
-#include "rpc_server/rpc_ep_setup.h"
-#include "printing/pcap.h"
-#include "printing.h"
+#include "printing/queue_process.h"
+#include "rpc_server/rpc_service_setup.h"
+#include "rpc_server/rpc_config.h"
#include "serverid.h"
#include "passdb.h"
#include "auth.h"
#include "messages.h"
#include "smbprofile.h"
+#include "lib/id_cache.h"
extern void start_epmd(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx);
-extern void start_spoolssd(struct event_context *ev_ctx,
- struct messaging_context *msg_ctx);
+extern void start_lsasd(struct event_context *ev_ctx,
+ struct messaging_context *msg_ctx);
#ifdef WITH_DFS
extern int dcelogin_atmost_once;
change_to_root_user();
reload_services(msg, smbd_server_conn->sock, False);
if (am_parent) {
- pcap_cache_reload(ev_ctx, msg,
- &reload_pcap_change_notify);
+ printing_subsystem_update(ev_ctx, msg, false);
}
}
}
if (s->parent->interactive) {
- smbd_process(sconn);
+ smbd_process(ev, sconn);
exit_server_cleanly("end of interactive mode");
return;
}
"serverid.tdb");
}
- smbd_process(smbd_server_conn);
+ smbd_process(ev, smbd_server_conn);
exit:
exit_server_cleanly("end of child");
return;
return true;
}
-static bool smbd_parent_housekeeping(const struct timeval *now, void *private_data)
-{
- struct messaging_context *msg_ctx =
- talloc_get_type_abort(private_data, struct messaging_context);
- time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
- time_t t = time_mono(NULL);
-
- DEBUG(5, ("parent housekeeping\n"));
-
- /* if periodic printcap rescan is enabled, see if it's time to reload */
- if ((printcap_cache_time != 0)
- && (t >= (last_printer_reload_time + printcap_cache_time))) {
- DEBUG( 3,( "Printcap cache time expired.\n"));
- pcap_cache_reload(messaging_event_context(msg_ctx),
- msg_ctx,
- &reload_pcap_change_notify);
- last_printer_reload_time = t;
- }
-
- return true;
-}
-
/****************************************************************************
Open the socket communication.
****************************************************************************/
return false;
}
- if (!(event_add_idle(ev_ctx, NULL,
- timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
- "parent_housekeeping", smbd_parent_housekeeping,
- msg_ctx))) {
- DEBUG(0, ("Could not add parent_housekeeping event\n"));
- return false;
- }
-
/* Listen to messages */
messaging_register(msg_ctx, NULL, MSG_SMB_SAM_SYNC, msg_sam_sync);
smb_pcap_updated);
brl_register_msgs(msg_ctx);
- msg_idmap_register_msgs(msg_ctx);
+ id_cache_register_msgs(msg_ctx);
+ id_cache_register_kill_msg(msg_ctx);
#ifdef CLUSTER_SUPPORT
if (lp_clustering()) {
exit(1);
}
- if (!printer_list_parent_init()) {
- exit(1);
- }
-
if (!W_ERROR_IS_OK(registry_init_full()))
exit(1);
- if (!print_backend_init(msg_ctx))
- exit(1);
-
/* Open the share_info.tdb here, so we don't have to open
after the fork on every single connection. This is a small
performance improvment and reduces the total number of system
return -1;
}
- if (is_daemon && !interactive) {
- const char *rpcsrv_type;
+ /* This MUST be done before start_epmd() because otherwise
+ * start_epmd() forks and races against dcesrv_ep_setup() to
+ * call directory_create_or_exist() */
+ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
+ DEBUG(0, ("Failed to create pipe directory %s - %s\n",
+ lp_ncalrpc_dir(), strerror(errno)));
+ return -1;
+ }
- rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
- "rpc_server", "epmapper",
- "none");
- if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
+ if (is_daemon && !interactive) {
+ if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) {
start_epmd(ev_ctx, msg_ctx);
}
}
exit(1);
}
- /* Publish nt printers, this requires a working winreg pipe */
- pcap_cache_reload(ev_ctx, msg_ctx, &reload_printers);
-
- /* only start the background queue daemon 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 */
+ /* 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 (is_daemon && !interactive) {
- if (is_daemon && !interactive
- && lp_parm_bool(-1, "smbd", "backgroundqueue", true)) {
- start_background_queue(ev_ctx, msg_ctx);
- }
+ if (rpc_lsasd_daemon() == RPC_DAEMON_FORK) {
+ start_lsasd(ev_ctx, msg_ctx);
+ }
- if (is_daemon && !_lp_disable_spoolss()) {
- const char *rpcsrv_type;
+ if (!_lp_disable_spoolss() &&
+ (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) {
+ bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true);
- /* start spoolss daemon */
- /* start as a separate daemon only if enabled */
- rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
- "rpc_server", "spoolss",
- "embedded");
- if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- start_spoolssd(ev_ctx, msg_ctx);
+ if (!printing_subsystem_init(ev_ctx, msg_ctx, true, bgq)) {
+ exit(1);
+ }
+ }
+ } else if (!_lp_disable_spoolss() &&
+ (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) {
+ if (!printing_subsystem_init(ev_ctx, msg_ctx, false, false)) {
+ exit(1);
}
}
/* Stop zombies */
smbd_setup_sig_chld_handler(ev_ctx);
- smbd_process(smbd_server_conn);
+ smbd_process(ev_ctx, smbd_server_conn);
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 */
+ printing_subsystem_update(ev_ctx, msg_ctx, false);
+
TALLOC_FREE(frame);
/* make sure we always have a valid stackframe */
frame = talloc_stackframe();