Back-port of Volkers fix.
[samba.git] / source / nsswitch / winbindd_dual.c
index 7176a25d62afe36a8d1aa2948457e0908178eae7..396eca7beb389c181f06b01166b4ed3599f082f4 100644 (file)
@@ -102,6 +102,7 @@ struct winbindd_async_request {
        void *private_data;
 };
 
+static void async_request_fail(struct winbindd_async_request *state);
 static void async_main_request_sent(void *private_data, BOOL success);
 static void async_request_sent(void *private_data, BOOL success);
 static void async_reply_recv(void *private_data, BOOL success);
@@ -127,6 +128,7 @@ void async_request(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
 
        state->mem_ctx = mem_ctx;
        state->child = child;
+       state->reply_timeout_event = NULL;
        state->request = request;
        state->response = response;
        state->continuation = continuation;
@@ -146,10 +148,7 @@ static void async_main_request_sent(void *private_data, BOOL success)
 
        if (!success) {
                DEBUG(5, ("Could not send async request\n"));
-
-               state->response->length = sizeof(struct winbindd_response);
-               state->response->result = WINBINDD_ERROR;
-               state->continuation(state->private_data, False);
+               async_request_fail(state);
                return;
        }
 
@@ -886,6 +885,7 @@ 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 (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) != 0) {
                DEBUG(0, ("Could not open child pipe: %s\n",
@@ -965,10 +965,13 @@ static BOOL fork_domain_child(struct winbindd_child *child)
        }
 
        /* Ensure we have no pending check_online events other
-          than one for this domain. */
+          than one for this domain or the primary domain. */
 
        for (domain = domain_list(); domain; domain = domain->next) {
-               if (domain != child->domain) {
+               if (domain->primary) {
+                       primary_domain = domain;
+               }
+               if ((domain != child->domain) && !domain->primary) {
                        TALLOC_FREE(domain->check_online_event);
                }
        }
@@ -985,6 +988,20 @@ static BOOL fork_domain_child(struct winbindd_child *child)
 
                set_domain_online_request(child->domain);
 
+               if (primary_domain != child->domain) {
+                       /* We need to talk to the primary
+                        * domain as well as the trusted
+                        * domain inside a trusted domain
+                        * child.
+                        * See the code in :
+                        * winbindd_dual_pam_auth_samlogon()
+                        * especially the calling of 
+                        * contact_domain = find_our_domain()
+                        * in the non-DC case for details.
+                        */
+                       set_domain_online_request(primary_domain);
+               }
+
                child->lockout_policy_event = event_add_timed(
                        winbind_event_context(), NULL, timeval_zero(),
                        "account_lockout_policy_handler",
@@ -1005,8 +1022,9 @@ static BOOL fork_domain_child(struct winbindd_child *child)
                main_loop_TALLOC_FREE();
 
                /* check for signals */
-               winbind_check_sigterm();
-               winbind_check_sighup();
+               winbind_check_sigterm(false);
+               winbind_check_sighup(override_logfile ? NULL :
+                       child->logfilename);
 
                run_events(winbind_event_context(), 0, NULL, NULL);