Changeset 165 for branches/samba-3.0/source/nsswitch/winbindd_dual.c
- Timestamp:
- Mar 11, 2009, 9:14:55 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/nsswitch/winbindd_dual.c
r158 r165 195 195 TALLOC_FREE(state->reply_timeout_event); 196 196 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)) { 201 203 kill(state->child_pid, SIGTERM); 202 204 … … 293 295 } 294 296 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 295 309 if ((child->pid == 0) && (!fork_domain_child(child))) { 296 /* Cancel all outstanding requests */ 310 /* fork_domain_child failed. 311 Cancel all outstanding requests */ 297 312 298 313 while (request != NULL) { 299 314 /* request might be free'd in the continuation */ 300 315 struct winbindd_async_request *next = request->next; 301 request->continuation(request->private_data, False); 316 317 async_request_fail(request); 302 318 request = next; 303 319 } … … 536 552 child->pid = 0; 537 553 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 538 565 schedule_async_request(child); 539 566 } … … 753 780 { 754 781 struct winbindd_domain *domain; 782 struct winbindd_domain *primary_domain = NULL; 755 783 const char *domainname = (const char *)buf; 756 784 … … 772 800 } 773 801 802 primary_domain = find_our_domain(); 803 774 804 /* Mark the requested domain offline. */ 775 805 … … 781 811 DEBUG(5,("child_msg_offline: marking %s offline.\n", domain->name)); 782 812 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 } 783 818 } 784 819 } … … 791 826 { 792 827 struct winbindd_domain *domain; 828 struct winbindd_domain *primary_domain = NULL; 793 829 const char *domainname = (const char *)buf; 794 830 … … 803 839 return; 804 840 } 841 842 primary_domain = find_our_domain(); 805 843 806 844 /* Set our global state as online. */ … … 818 856 winbindd_flush_negative_conn_cache(domain); 819 857 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 } 820 868 } 821 869 } … … 881 929 } 882 930 931 bool reinit_after_fork(struct messaging_context *msg_ctx, 932 struct event_context *ev_ctx, 933 bool parent_longlived); 934 void ccache_remove_all_after_fork(void); 935 936 bool 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 883 979 static BOOL fork_domain_child(struct winbindd_child *child) 884 980 { 885 981 int fdpair[2]; 886 982 struct winbindd_cli_state state; 887 struct winbindd_domain *domain;888 983 struct winbindd_domain *primary_domain = NULL; 889 984 … … 916 1011 child->event.fd = fdpair[1]; 917 1012 child->event.flags = 0; 918 child->requests = NULL;919 1013 add_fd_event(&child->event); 920 1014 /* We're ok with online/offline messages now. */ … … 932 1026 933 1027 /* tdb needs special fork handling */ 934 if ( tdb_reopen_all(1) == -1) {935 DEBUG(0, ("tdb_reopen_allfailed.\n"));1028 if (!winbindd_reinit_after_fork(child->logfilename)) { 1029 DEBUG(0, ("winbindd_reinit_after_fork failed.\n")); 936 1030 _exit(0); 937 1031 } 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);952 1032 953 1033 /* The child is ok with online/offline messages now. */ … … 960 1040 NULL); 961 1041 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. */ 962 1050 if ( child->domain ) { 963 1051 child->domain->startup = True; 964 1052 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 } 984 1065 985 1066 /* We might be in the idmap child...*/
Note:
See TracChangeset
for help on using the changeset viewer.