dump_event_list(winbind_event_context());
}
+bool winbindd_reinit_after_fork(const char *logfilename)
+{
+ struct winbindd_domain *domain;
+ struct winbindd_child *cl;
+
+ if (!reinit_after_fork(winbind_messaging_context(),
+ winbind_event_context(), true)) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
+ return false;
+ }
+
+ close_conns_after_fork();
+
+ if (!override_logfile && logfilename) {
+ lp_set_logfile(logfilename);
+ reopen_logs();
+ }
+
+ /* Don't handle the same messages as our parent. */
+ messaging_deregister(winbind_messaging_context(),
+ MSG_SMB_CONF_UPDATED, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_SHUTDOWN, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_WINBIND_OFFLINE, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_WINBIND_ONLINE, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_WINBIND_ONLINESTATUS, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_DUMP_EVENT_LIST, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_WINBIND_DUMP_DOMAIN_LIST, NULL);
+ messaging_deregister(winbind_messaging_context(),
+ MSG_DEBUG, NULL);
+
+ /* We have destroyed all events in the winbindd_event_context
+ * in reinit_after_fork(), so clean out all possible pending
+ * event pointers. */
+
+ /* Deal with check_online_events. */
+
+ for (domain = domain_list(); domain; domain = domain->next) {
+ TALLOC_FREE(domain->check_online_event);
+ }
+
+ /* Ensure we're not handling a credential cache event inherited
+ * from our parent. */
+
+ ccache_remove_all_after_fork();
+
+ /* Destroy all possible events in child list. */
+ for (cl = children; cl != NULL; cl = cl->next) {
+ struct winbindd_async_request *request;
+
+ for (request = cl->requests; request; request = request->next) {
+ TALLOC_FREE(request->reply_timeout_event);
+ }
+ TALLOC_FREE(cl->lockout_policy_event);
+ TALLOC_FREE(cl->machine_password_change_event);
+
+ /* Children should never be able to send
+ * each other messages, all meesages must
+ * go through the parent.
+ */
+ cl->pid = (pid_t)0;
+ }
+ /*
+ * This is a little tricky, we don't want child
+ * to send MSG_WINBIND_ONLINE to idmap_child().
+ * If we are in the child of trusted domain or
+ * in the process created by fork_child_dc_connect().
+ * And the trusted domain cannot go online,
+ * fork_child_dc_connection() sends MSG_WINBIND_ONLINE
+ * periodically to idmap_child().
+ * look, fork_child_dc_connect() ---> getdcs() --->
+ * get_dc_name_via_netlogon() ---> cm_connect_netlogon()
+ * ---> init_dc_connection() ---> cm_open_connection --->
+ * set_domain_online(), here send MSG_WINBIND_ONLINE to
+ * idmap_child().
+ */
+ cl = idmap_child();
+ cl->pid = (pid_t)0;
+
+ return true;
+}
static bool fork_domain_child(struct winbindd_child *child)
{
int fdpair[2];
struct winbindd_cli_state state;
- struct winbindd_domain *domain;
struct winbindd_domain *primary_domain = NULL;
if (child->domain) {
DLIST_ADD(children, child);
child->event.fd = fdpair[1];
child->event.flags = 0;
- child->requests = NULL;
add_fd_event(&child->event);
return True;
}
state.sock = fdpair[0];
close(fdpair[1]);
- if (!reinit_after_fork(winbind_messaging_context(),
- winbind_event_context(), true)) {
- DEBUG(0,("reinit_after_fork() failed\n"));
+ if (!winbindd_reinit_after_fork(child->logfilename)) {
_exit(0);
}
- close_conns_after_fork();
-
- /* Ensure we're not handling an event inherited from
- our parent. */
- ccache_remove_all_after_fork();
-
- if (!override_logfile) {
- lp_set_logfile(child->logfilename);
- reopen_logs();
- }
-
- /* Don't handle the same messages as our parent. */
- messaging_deregister(winbind_messaging_context(),
- MSG_SMB_CONF_UPDATED, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_SHUTDOWN, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_WINBIND_OFFLINE, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_WINBIND_ONLINE, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_WINBIND_ONLINESTATUS, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_DUMP_EVENT_LIST, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_WINBIND_DUMP_DOMAIN_LIST, NULL);
- messaging_deregister(winbind_messaging_context(),
- MSG_DEBUG, NULL);
-
/* Handle online/offline messages. */
messaging_register(winbind_messaging_context(), NULL,
MSG_WINBIND_OFFLINE, child_msg_offline);
if (primary_domain == NULL) {
smb_panic("no primary domain found");
}
- /* we have destroy all time event in reinit_after_fork()
- * set check_online_event to NULL */
- for (domain = domain_list(); domain; domain = domain->next) {
- domain->check_online_event = NULL;
- }
+
/* It doesn't matter if we allow cache login,
* try to bring domain online after fork. */
if ( child->domain ) {
}
}
}
+
+ /*
+ * We are in idmap child, make sure that we set the
+ * check_online_event to bring primary domain online.
+ */
+ if (child == idmap_child()) {
+ set_domain_online_request(primary_domain);
+ }
/* We might be in the idmap child...*/
if (child->domain && !(child->domain->internal) &&
DEBUG(0,("select error occured\n"));
TALLOC_FREE(frame);
perror("select");
- return False;
+ _exit(1);
}
/* fetch a request from the main daemon */
if (state.finished) {
/* we lost contact with our parent */
- exit(0);
+ _exit(0);
}
DEBUG(4,("child daemon request %d\n", (int)state.request.cmd));