Ignore:
Timestamp:
Mar 11, 2009, 9:14:55 AM (16 years ago)
Author:
Paul Smedley
Message:

Add 'missing' 3.0.34 diffs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/nsswitch/winbindd_dual.c

    r158 r165  
    195195        TALLOC_FREE(state->reply_timeout_event);
    196196
    197         SMB_ASSERT(state->child_pid != (pid_t)0);
    198 
    199         /* If not already reaped, send kill signal to child. */
    200         if (state->child->pid == state->child_pid) {
     197        /* If child exists and is not already reaped,
     198           send kill signal to child. */
     199
     200        if ((state->child->pid != (pid_t)0) &&
     201                        (state->child->pid != (pid_t)-1) &&
     202                        (state->child->pid == state->child_pid)) {
    201203                kill(state->child_pid, SIGTERM);
    202204
     
    293295        }
    294296
     297        /*
     298         * This may be a reschedule, so we might
     299         * have an existing timeout event pending on
     300         * the first entry in the child->requests list
     301         * (we only send one request at a time).
     302         * Ensure we free it before we reschedule.
     303         * Bug #5814, from hargagan <shargagan@novell.com>.
     304         * JRA.
     305         */
     306
     307        TALLOC_FREE(request->reply_timeout_event);
     308
    295309        if ((child->pid == 0) && (!fork_domain_child(child))) {
    296                 /* Cancel all outstanding requests */
     310                /* fork_domain_child failed.
     311                   Cancel all outstanding requests */
    297312
    298313                while (request != NULL) {
    299314                        /* request might be free'd in the continuation */
    300315                        struct winbindd_async_request *next = request->next;
    301                         request->continuation(request->private_data, False);
     316
     317                        async_request_fail(request);
    302318                        request = next;
    303319                }
     
    536552        child->pid = 0;
    537553
     554        if (child->requests) {
     555                /*
     556                 * schedule_async_request() will also
     557                 * clear this event but the call is
     558                 * idempotent so it doesn't hurt to
     559                 * cover all possible future code
     560                 * paths. JRA.
     561                 */
     562                TALLOC_FREE(child->requests->reply_timeout_event);
     563        }
     564
    538565        schedule_async_request(child);
    539566}
     
    753780{
    754781        struct winbindd_domain *domain;
     782        struct winbindd_domain *primary_domain = NULL;
    755783        const char *domainname = (const char *)buf;
    756784
     
    772800        }
    773801
     802        primary_domain = find_our_domain();
     803
    774804        /* Mark the requested domain offline. */
    775805
     
    781811                        DEBUG(5,("child_msg_offline: marking %s offline.\n", domain->name));
    782812                        set_domain_offline(domain);
     813                        /* we are in the trusted domain, set the primary domain
     814                         * offline too */
     815                        if (domain != primary_domain) {
     816                                set_domain_offline(primary_domain);
     817                        }
    783818                }
    784819        }
     
    791826{
    792827        struct winbindd_domain *domain;
     828        struct winbindd_domain *primary_domain = NULL;
    793829        const char *domainname = (const char *)buf;
    794830
     
    803839                return;
    804840        }
     841
     842        primary_domain = find_our_domain();
    805843
    806844        /* Set our global state as online. */
     
    818856                        winbindd_flush_negative_conn_cache(domain);
    819857                        set_domain_online_request(domain);
     858
     859                        /* we can be in trusted domain, which will contact primary domain
     860                         * we have to bring primary domain online in trusted domain process
     861                         * see, winbindd_dual_pam_auth() --> winbindd_dual_pam_auth_samlogon()
     862                         * --> contact_domain = find_our_domain()
     863                         * */
     864                        if (domain != primary_domain) {
     865                                winbindd_flush_negative_conn_cache(primary_domain);
     866                                set_domain_online_request(primary_domain);
     867                        }
    820868                }
    821869        }
     
    881929}
    882930
     931bool reinit_after_fork(struct messaging_context *msg_ctx,
     932                        struct event_context *ev_ctx,
     933                        bool parent_longlived);
     934void ccache_remove_all_after_fork(void);
     935
     936bool winbindd_reinit_after_fork(const char *logfile)
     937{
     938        struct winbindd_domain *dom;
     939        struct winbindd_child *cl;
     940
     941        if (!reinit_after_fork(NULL,
     942                                winbind_event_context(), true)) {
     943                DEBUG(0, ("reinit_after_fork failed.\n"));
     944                return false;
     945        }
     946
     947        close_conns_after_fork();
     948
     949        if (!override_logfile && logfile) {
     950                lp_set_logfile(logfile);
     951                reopen_logs();
     952        }
     953
     954        /* Don't handle the same messages as our parent. */
     955        message_deregister(MSG_SMB_CONF_UPDATED);
     956        message_deregister(MSG_SHUTDOWN);
     957        message_deregister(MSG_WINBIND_OFFLINE);
     958        message_deregister(MSG_WINBIND_ONLINE);
     959        message_deregister(MSG_WINBIND_ONLINESTATUS);
     960
     961        ccache_remove_all_after_fork();
     962       
     963        for (dom = domain_list(); dom; dom = dom->next) {
     964                TALLOC_FREE(dom->check_online_event);
     965        }
     966
     967        for (cl = children; cl; cl = cl->next) {
     968                struct winbindd_async_request *request;
     969
     970                for (request = cl->requests; request; request = request->next) {
     971                        TALLOC_FREE(request->reply_timeout_event);
     972                }
     973                TALLOC_FREE(cl->lockout_policy_event);
     974        }
     975
     976        return true;
     977}
     978
    883979static BOOL fork_domain_child(struct winbindd_child *child)
    884980{
    885981        int fdpair[2];
    886982        struct winbindd_cli_state state;
    887         struct winbindd_domain *domain;
    888983        struct winbindd_domain *primary_domain = NULL;
    889984
     
    9161011                child->event.fd = fdpair[1];
    9171012                child->event.flags = 0;
    918                 child->requests = NULL;
    9191013                add_fd_event(&child->event);
    9201014                /* We're ok with online/offline messages now. */
     
    9321026
    9331027        /* tdb needs special fork handling */
    934         if (tdb_reopen_all(1) == -1) {
    935                 DEBUG(0,("tdb_reopen_all failed.\n"));
     1028        if (!winbindd_reinit_after_fork(child->logfilename)) {
     1029                DEBUG(0, ("winbindd_reinit_after_fork failed.\n"));
    9361030                _exit(0);
    9371031        }
    938 
    939         close_conns_after_fork();
    940 
    941         if (!override_logfile) {
    942                 lp_set_logfile(child->logfilename);
    943                 reopen_logs();
    944         }
    945 
    946         /* Don't handle the same messages as our parent. */
    947         message_deregister(MSG_SMB_CONF_UPDATED);
    948         message_deregister(MSG_SHUTDOWN);
    949         message_deregister(MSG_WINBIND_OFFLINE);
    950         message_deregister(MSG_WINBIND_ONLINE);
    951         message_deregister(MSG_WINBIND_ONLINESTATUS);
    9521032
    9531033        /* The child is ok with online/offline messages now. */
     
    9601040                         NULL);
    9611041
     1042        primary_domain = find_our_domain();
     1043
     1044        if (primary_domain == NULL) {
     1045                smb_panic("no primary domain found");
     1046        }
     1047
     1048        /* It doesn't matter if we allow cache login,
     1049         * try to bring domain online after fork. */
    9621050        if ( child->domain ) {
    9631051                child->domain->startup = True;
    9641052                child->domain->startup_time = time(NULL);
    965         }
    966 
    967         /* Ensure we have no pending check_online events other
    968            than one for this domain or the primary domain. */
    969 
    970         for (domain = domain_list(); domain; domain = domain->next) {
    971                 if (domain->primary) {
    972                         primary_domain = domain;
    973                 }
    974                 if ((domain != child->domain) && !domain->primary) {
    975                         TALLOC_FREE(domain->check_online_event);
    976                 }
    977         }
    978 
    979         /* Ensure we're not handling an event inherited from
    980            our parent. */
    981 
    982         cancel_named_event(winbind_event_context(),
    983                            "krb5_ticket_refresh_handler");
     1053                /* we can be in primary domain or in trusted domain
     1054                 * If we are in trusted domain, set the primary domain
     1055                 * in start-up mode */
     1056                if (!(child->domain->internal)) {
     1057                        set_domain_online_request(child->domain);
     1058                        if (!(child->domain->primary)) {
     1059                                primary_domain->startup = True;
     1060                                primary_domain->startup_time = time(NULL);
     1061                                set_domain_online_request(primary_domain);
     1062                        }
     1063                }
     1064        }
    9841065
    9851066        /* We might be in the idmap child...*/
Note: See TracChangeset for help on using the changeset viewer.