*/
#include "includes.h"
+#include "system/filesys.h"
#include "popt_common.h"
+#include "smbd/smbd.h"
#include "smbd/globals.h"
-#include "librpc/gen_ndr/messaging.h"
-#include "registry.h"
#include "registry/reg_init_full.h"
#include "libcli/auth/schannel.h"
#include "secrets.h"
#include "memcache.h"
#include "ctdbd_conn.h"
#include "printing/printer_list.h"
-#include "rpc_server/srv_rpc_register.h"
+#include "rpc_server/rpc_ep_setup.h"
+#include "printing/pcap.h"
+#include "printing.h"
+#include "serverid.h"
+#include "passdb.h"
+#include "auth.h"
+#include "messages.h"
+#include "smbprofile.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);
#ifdef WITH_DFS
extern int dcelogin_atmost_once;
#endif /* WITH_DFS */
-static void smbd_set_server_fd(int fd)
-{
- struct smbd_server_connection *sconn = smbd_server_conn;
- char addr[INET6_ADDRSTRLEN];
- const char *name;
-
- sconn->sock = fd;
-
- /*
- * Initialize sconn->client_id: If we can't find the client's
- * name, default to its address.
- */
-
- client_addr(fd, sconn->client_id.addr, sizeof(sconn->client_id.addr));
-
- name = client_name(sconn->sock);
- if (strcmp(name, "UNKNOWN") != 0) {
- name = talloc_strdup(sconn, name);
- } else {
- name = NULL;
- }
- sconn->client_id.name =
- (name != NULL) ? name : sconn->client_id.addr;
-
- sub_set_socket_ids(sconn->client_id.addr, sconn->client_id.name,
- client_socket_addr(sconn->sock, addr,
- sizeof(addr)));
-}
-
struct event_context *smbd_event_context(void)
{
return server_event_context();
struct server_id server_id,
DATA_BLOB *data)
{
+ struct tevent_context *ev_ctx =
+ talloc_get_type_abort(private_data, struct tevent_context);
+
DEBUG(10,("smb_conf_updated: Got message saying smb.conf was "
"updated. Reloading.\n"));
change_to_root_user();
reload_services(msg, smbd_server_conn->sock, False);
if (am_parent) {
- pcap_cache_reload(server_event_context(), msg,
+ pcap_cache_reload(ev_ctx, msg,
&reload_pcap_change_notify);
}
}
struct server_id server_id,
DATA_BLOB *data)
{
+ struct tevent_context *ev_ctx =
+ talloc_get_type_abort(private_data, struct tevent_context);
+
DEBUG(10,("Got message saying pcap was updated. Reloading.\n"));
change_to_root_user();
- reload_printers(server_event_context(), msg);
+ reload_printers(ev_ctx, msg);
}
/*******************************************************************
continue;
}
+ /* Keep the first port for mDNS service
+ * registration.
+ */
+ if (dns_port == 0) {
+ dns_port = port;
+ }
+
if (!smbd_open_one_socket(parent, ifss, port)) {
return false;
}
messaging_register(msg_ctx, NULL, MSG_SHUTDOWN, msg_exit_server);
messaging_register(msg_ctx, NULL, MSG_SMB_FILE_RENAME,
msg_file_was_renamed);
- messaging_register(msg_ctx, NULL, MSG_SMB_CONF_UPDATED,
+ messaging_register(msg_ctx, server_event_context(), MSG_SMB_CONF_UPDATED,
smb_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_PRINTER_PCAP, smb_pcap_updated);
+ messaging_register(msg_ctx, server_event_context(), MSG_PRINTER_PCAP,
+ smb_pcap_updated);
brl_register_msgs(msg_ctx);
+ msg_idmap_register_msgs(msg_ctx);
+
#ifdef CLUSTER_SUPPORT
if (lp_clustering()) {
ctdbd_register_reconfigure(messaging_ctdbd_connection());
gain_root_privilege();
gain_root_group_privilege();
- fault_setup((void (*)(void *))exit_server_fault);
- dump_core_setup("smbd");
+ fault_setup();
+ dump_core_setup("smbd", lp_logfile());
/* we are never interested in SIGPIPE */
BlockSignals(True,SIGPIPE);
}
if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
- DEBUG(0, ("error opening config file\n"));
+ DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE()));
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 (!reload_services(smbd_messaging_context(), -1, False)) {
+ if (!reload_services(NULL, -1, False)) {
exit(1);
}
return -1;
}
+ if (is_daemon && !interactive) {
+ const char *rpcsrv_type;
+
+ rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "rpc_server", "epmapper",
+ "none");
+ if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
+ start_epmd(smbd_event_context(),
+ smbd_server_conn->msg_ctx);
+ }
+ }
+
if (!dcesrv_ep_setup(smbd_event_context(), smbd_server_conn->msg_ctx)) {
exit(1);
}
smbd_messaging_context());
}
+ if (is_daemon && !_lp_disable_spoolss()) {
+ const char *rpcsrv_type;
+
+ /* 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(smbd_event_context(),
+ smbd_messaging_context());
+ }
+ }
+
if (!is_daemon) {
/* inetd mode */
TALLOC_FREE(frame);