nsswitch/winbindd_dual.c

ソースコードを見る。

データ構造

struct  winbindd_async_request
struct  domain_request_state
struct  winbindd_child_dispatch_table

関数

static void child_read_request (struct winbindd_cli_state *state)
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)
static void schedule_async_request (struct winbindd_child *child)
void async_request (TALLOC_CTX *mem_ctx, struct winbindd_child *child, struct winbindd_request *request, struct winbindd_response *response, void(*continuation)(void *private_data, BOOL success), void *private_data)
static void async_request_timeout_handler (struct event_context *ctx, struct timed_event *te, const struct timeval *now, void *private_data)
static BOOL fork_domain_child (struct winbindd_child *child)
static void domain_init_recv (void *private_data_data, BOOL success)
void async_domain_request (TALLOC_CTX *mem_ctx, struct winbindd_domain *domain, struct winbindd_request *request, struct winbindd_response *response, void(*continuation)(void *private_data_data, BOOL success), void *private_data_data)
static void recvfrom_child (void *private_data_data, BOOL success)
void sendto_child (struct winbindd_cli_state *state, struct winbindd_child *child)
void sendto_domain (struct winbindd_cli_state *state, struct winbindd_domain *domain)
static void child_process_request (struct winbindd_domain *domain, struct winbindd_cli_state *state)
void setup_domain_child (struct winbindd_domain *domain, struct winbindd_child *child, const char *explicit_logfile)
void winbind_child_died (pid_t pid)
void winbindd_flush_negative_conn_cache (struct winbindd_domain *domain)
void winbind_msg_offline (int msg_type, struct process_id src, void *buf, size_t len, void *private_data)
void winbind_msg_online (int msg_type, struct process_id src, void *buf, size_t len, void *private_data)
void winbind_msg_onlinestatus (int msg_type, struct process_id src, void *buf, size_t len, void *private_data)
static void account_lockout_policy_handler (struct event_context *ctx, struct timed_event *te, const struct timeval *now, void *private_data)
static void child_msg_offline (int msg_type, struct process_id src, void *buf, size_t len, void *private_data)
static void child_msg_online (int msg_type, struct process_id src, void *buf, size_t len, void *private_data)
static const char * collect_onlinestatus (TALLOC_CTX *mem_ctx)
static void child_msg_onlinestatus (int msg_type, struct process_id src, void *buf, size_t len, void *private_data)

変数

BOOL override_logfile
static struct winbindd_child_dispatch_table child_dispatch_table []
winbindd_childchildren = NULL


関数

static void child_read_request ( struct winbindd_cli_state state  )  [static]

winbindd_dual.c41 行で定義されています。

参照先 winbindd_request::datawinbindd_request::extra_datawinbindd_request::extra_lenwinbindd_cli_state::finishedlenread_data()winbindd_cli_state::requestwinbindd_cli_state::sock.

00042 {
00043         ssize_t len;
00044 
00045         /* Read data */
00046 
00047         len = read_data(state->sock, (char *)&state->request,
00048                         sizeof(state->request));
00049 
00050         if (len != sizeof(state->request)) {
00051                 DEBUG(len > 0 ? 0 : 3, ("Got invalid request length: %d\n", (int)len));
00052                 state->finished = True;
00053                 return;
00054         }
00055 
00056         if (state->request.extra_len == 0) {
00057                 state->request.extra_data.data = NULL;
00058                 return;
00059         }
00060 
00061         DEBUG(10, ("Need to read %d extra bytes\n", (int)state->request.extra_len));
00062 
00063         state->request.extra_data.data =
00064                 SMB_MALLOC_ARRAY(char, state->request.extra_len + 1);
00065 
00066         if (state->request.extra_data.data == NULL) {
00067                 DEBUG(0, ("malloc failed\n"));
00068                 state->finished = True;
00069                 return;
00070         }
00071 
00072         /* Ensure null termination */
00073         state->request.extra_data.data[state->request.extra_len] = '\0';
00074 
00075         len = read_data(state->sock, state->request.extra_data.data,
00076                         state->request.extra_len);
00077 
00078         if (len != state->request.extra_len) {
00079                 DEBUG(0, ("Could not read extra data\n"));
00080                 state->finished = True;
00081                 return;
00082         }
00083 }

static void async_request_fail ( struct winbindd_async_request state  )  [static]

winbindd_dual.c191 行で定義されています。

参照先 winbindd_async_request::childwinbindd_async_request::child_pidwinbindd_async_request::continuationwinbindd_response::lengthwinbindd_child::pidwinbindd_async_request::private_datawinbindd_async_request::reply_timeout_eventwinbindd_child::requestswinbindd_async_request::responsewinbindd_response::resultwinbind_child_died()WINBINDD_ERROR.

参照元 async_main_request_sent()async_reply_recv()async_request_sent().

00192 {
00193         DLIST_REMOVE(state->child->requests, state);
00194 
00195         TALLOC_FREE(state->reply_timeout_event);
00196 
00197         SMB_ASSERT(state->child_pid != (pid_t)0);
00198 
00199         /* If not already reaped, send kill signal to child. */
00200         if (state->child->pid == state->child_pid) {
00201                 kill(state->child_pid, SIGTERM);
00202 
00203                 /* 
00204                  * Close the socket to the child.
00205                  */
00206                 winbind_child_died(state->child_pid);
00207         }
00208 
00209         state->response->length = sizeof(struct winbindd_response);
00210         state->response->result = WINBINDD_ERROR;
00211         state->continuation(state->private_data, False);
00212 }

static void async_main_request_sent ( void *  private_data,
BOOL  success 
) [static]

winbindd_dual.c144 行で定義されています。

参照先 async_request_fail()async_request_sent()winbindd_async_request::childwinbindd_request::datawinbindd_child::eventwinbindd_request::extra_datawinbindd_request::extra_lenwinbindd_async_request::requestsetup_async_write().

参照元 schedule_async_request().

00145 {
00146         struct winbindd_async_request *state =
00147                 talloc_get_type_abort(private_data, struct winbindd_async_request);
00148 
00149         if (!success) {
00150                 DEBUG(5, ("Could not send async request\n"));
00151                 async_request_fail(state);
00152                 return;
00153         }
00154 
00155         if (state->request->extra_len == 0) {
00156                 async_request_sent(private_data, True);
00157                 return;
00158         }
00159 
00160         setup_async_write(&state->child->event, state->request->extra_data.data,
00161                           state->request->extra_len,
00162                           async_request_sent, state);
00163 }

static void async_request_sent ( void *  private_data,
BOOL  success 
) [static]

winbindd_dual.c214 行で定義されています。

参照先 async_reply_recv()async_request_fail()async_request_timeout_handler()winbindd_async_request::childwinbindd_async_request::child_pidwinbindd_child::eventevent_add_timed()winbindd_async_request::reply_timeout_eventwinbindd_async_request::responsewinbindd_response::resultsetup_async_read()smb_panic()timeval_current_ofs()winbind_event_context().

参照元 async_main_request_sent().

00215 {
00216         struct winbindd_async_request *state =
00217                 talloc_get_type_abort(private_data_data, struct winbindd_async_request);
00218 
00219         if (!success) {
00220                 DEBUG(5, ("Could not send async request to child pid %u\n",
00221                         (unsigned int)state->child_pid ));
00222                 async_request_fail(state);
00223                 return;
00224         }
00225 
00226         /* Request successfully sent to the child, setup the wait for reply */
00227 
00228         setup_async_read(&state->child->event,
00229                          &state->response->result,
00230                          sizeof(state->response->result),
00231                          async_reply_recv, state);
00232 
00233         /* 
00234          * Set up a timeout of 300 seconds for the response.
00235          * If we don't get it close the child socket and
00236          * report failure.
00237          */
00238 
00239         state->reply_timeout_event = event_add_timed(winbind_event_context(),
00240                                                         NULL,
00241                                                         timeval_current_ofs(300,0),
00242                                                         "async_request_timeout",
00243                                                         async_request_timeout_handler,
00244                                                         state);
00245         if (!state->reply_timeout_event) {
00246                 smb_panic("async_request_sent: failed to add timeout handler.\n");
00247         }
00248 }

static void async_reply_recv ( void *  private_data,
BOOL  success 
) [static]

winbindd_dual.c250 行で定義されています。

参照先 async_request_fail()cache_cleanup_response()cache_retrieve_response()winbindd_async_request::childwinbindd_async_request::child_pidwinbindd_async_request::continuationwinbindd_response::lengthwinbindd_async_request::private_datawinbindd_async_request::reply_timeout_eventwinbindd_child::requestswinbindd_async_request::responseschedule_async_request().

参照元 async_request_sent()async_request_timeout_handler().

00251 {
00252         struct winbindd_async_request *state =
00253                 talloc_get_type_abort(private_data, struct winbindd_async_request);
00254         struct winbindd_child *child = state->child;
00255 
00256         TALLOC_FREE(state->reply_timeout_event);
00257 
00258         state->response->length = sizeof(struct winbindd_response);
00259 
00260         if (!success) {
00261                 DEBUG(5, ("Could not receive async reply from child pid %u\n",
00262                         (unsigned int)state->child_pid ));
00263 
00264                 cache_cleanup_response(state->child_pid);
00265                 async_request_fail(state);
00266                 return;
00267         }
00268 
00269         SMB_ASSERT(cache_retrieve_response(state->child_pid,
00270                                            state->response));
00271 
00272         cache_cleanup_response(state->child_pid);
00273         
00274         DLIST_REMOVE(child->requests, state);
00275 
00276         schedule_async_request(child);
00277 
00278         state->continuation(state->private_data, True);
00279 }

static void schedule_async_request ( struct winbindd_child child  )  [static]

winbindd_dual.c283 行で定義されています。

参照先 async_main_request_sent()winbindd_async_request::childwinbindd_child::eventfd_event::flagsfork_domain_child()winbindd_async_request::nextwinbindd_child::pidwinbindd_async_request::requestwinbindd_child::requestssetup_async_write().

参照元 async_reply_recv()async_request().

00284 {
00285         struct winbindd_async_request *request = child->requests;
00286 
00287         if (request == NULL) {
00288                 return;
00289         }
00290 
00291         if (child->event.flags != 0) {
00292                 return;         /* Busy */
00293         }
00294 
00295         if ((child->pid == 0) && (!fork_domain_child(child))) {
00296                 /* Cancel all outstanding requests */
00297 
00298                 while (request != NULL) {
00299                         /* request might be free'd in the continuation */
00300                         struct winbindd_async_request *next = request->next;
00301                         request->continuation(request->private_data, False);
00302                         request = next;
00303                 }
00304                 return;
00305         }
00306 
00307         /* Now we know who we're sending to - remember the pid. */
00308         request->child_pid = child->pid;
00309 
00310         setup_async_write(&child->event, request->request,
00311                           sizeof(*request->request),
00312                           async_main_request_sent, request);
00313 
00314         return;
00315 }

void async_request ( TALLOC_CTX mem_ctx,
struct winbindd_child child,
struct winbindd_request request,
struct winbindd_response response,
void(*)(void *private_data, BOOL success)  continuation,
void *  private_data 
)

winbindd_dual.c111 行で定義されています。

参照先 winbindd_async_request::childwinbindd_async_request::continuationwinbindd_async_request::mem_ctxwinbindd_async_request::private_datawinbindd_async_request::reply_timeout_eventwinbindd_async_request::requestwinbindd_child::requestswinbindd_async_request::responseschedule_async_request().

参照元 async_domain_request()do_async()domain_init_recv()init_child_connection()init_child_getdc_recv()sendto_child().

00116 {
00117         struct winbindd_async_request *state;
00118 
00119         SMB_ASSERT(continuation != NULL);
00120 
00121         state = TALLOC_P(mem_ctx, struct winbindd_async_request);
00122 
00123         if (state == NULL) {
00124                 DEBUG(0, ("talloc failed\n"));
00125                 continuation(private_data, False);
00126                 return;
00127         }
00128 
00129         state->mem_ctx = mem_ctx;
00130         state->child = child;
00131         state->reply_timeout_event = NULL;
00132         state->request = request;
00133         state->response = response;
00134         state->continuation = continuation;
00135         state->private_data = private_data;
00136 
00137         DLIST_ADD_END(child->requests, state, struct winbindd_async_request *);
00138 
00139         schedule_async_request(child);
00140 
00141         return;
00142 }

static void async_request_timeout_handler ( struct event_context ctx,
struct timed_event te,
const struct timeval *  now,
void *  private_data 
) [static]

winbindd_dual.c170 行で定義されています。

参照先 async_reply_recv()winbindd_async_request::child_pid.

参照元 async_request_sent().

00174 {
00175         struct winbindd_async_request *state =
00176                 talloc_get_type_abort(private_data, struct winbindd_async_request);
00177 
00178         DEBUG(0,("async_request_timeout_handler: child pid %u is not responding. "
00179                 "Closing connection to it.\n",
00180                 state->child_pid ));
00181 
00182         /* Deal with the reply - set to error. */
00183         async_reply_recv(private_data, False);
00184 }

static BOOL fork_domain_child ( struct winbindd_child child  )  [static]

winbindd_dual.c883 行で定義されています。

参照先 add_fd_event()CatchChild()winbindd_domain::check_online_eventwinbindd_domain::childchild_msg_offline()child_msg_online()child_msg_onlinestatus()childrenclose_conns_after_fork()winbindd_child::domaindomain_list()errnowinbindd_child::eventfd_event::fdfd_event::flagswinbindd_child::logfilenamemessage_block()message_deregister()message_register()message_unblock()winbindd_domain::nextwinbindd_child::nextoverride_logfilewinbindd_child::pidwinbindd_cli_state::pidwinbindd_child::prevwinbindd_domain::primaryreopen_logs()winbindd_child::requestswinbindd_cli_state::sockwinbindd_domain::startupwinbindd_domain::startup_timestrerror()sys_fork()sys_getpid()tdb_reopen_all().

参照元 schedule_async_request().

00884 {
00885         int fdpair[2];
00886         struct winbindd_cli_state state;
00887         struct winbindd_domain *domain;
00888         struct winbindd_domain *primary_domain = NULL;
00889 
00890         if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) != 0) {
00891                 DEBUG(0, ("Could not open child pipe: %s\n",
00892                           strerror(errno)));
00893                 return False;
00894         }
00895 
00896         ZERO_STRUCT(state);
00897         state.pid = sys_getpid();
00898 
00899         /* Ensure we don't process messages whilst we're
00900            changing the disposition for the child. */
00901         message_block();
00902 
00903         child->pid = sys_fork();
00904 
00905         if (child->pid == -1) {
00906                 DEBUG(0, ("Could not fork: %s\n", strerror(errno)));
00907                 message_unblock();
00908                 return False;
00909         }
00910 
00911         if (child->pid != 0) {
00912                 /* Parent */
00913                 close(fdpair[0]);
00914                 child->next = child->prev = NULL;
00915                 DLIST_ADD(children, child);
00916                 child->event.fd = fdpair[1];
00917                 child->event.flags = 0;
00918                 child->requests = NULL;
00919                 add_fd_event(&child->event);
00920                 /* We're ok with online/offline messages now. */
00921                 message_unblock();
00922                 return True;
00923         }
00924 
00925         /* Child */
00926 
00927         /* Stop zombies in children */
00928         CatchChild();
00929 
00930         state.sock = fdpair[0];
00931         close(fdpair[1]);
00932 
00933         /* tdb needs special fork handling */
00934         if (tdb_reopen_all(1) == -1) {
00935                 DEBUG(0,("tdb_reopen_all failed.\n"));
00936                 _exit(0);
00937         }
00938 
00939         close_conns_after_fork();
00940 
00941         if (!override_logfile) {
00942                 lp_set_logfile(child->logfilename);
00943                 reopen_logs();
00944         }
00945 
00946         /* Don't handle the same messages as our parent. */
00947         message_deregister(MSG_SMB_CONF_UPDATED);
00948         message_deregister(MSG_SHUTDOWN);
00949         message_deregister(MSG_WINBIND_OFFLINE);
00950         message_deregister(MSG_WINBIND_ONLINE);
00951         message_deregister(MSG_WINBIND_ONLINESTATUS);
00952 
00953         /* The child is ok with online/offline messages now. */
00954         message_unblock();
00955 
00956         /* Handle online/offline messages. */
00957         message_register(MSG_WINBIND_OFFLINE, child_msg_offline, NULL);
00958         message_register(MSG_WINBIND_ONLINE, child_msg_online, NULL);
00959         message_register(MSG_WINBIND_ONLINESTATUS, child_msg_onlinestatus,
00960                          NULL);
00961 
00962         if ( child->domain ) {
00963                 child->domain->startup = True;
00964                 child->domain->startup_time = time(NULL);
00965         }
00966 
00967         /* Ensure we have no pending check_online events other
00968            than one for this domain or the primary domain. */
00969 
00970         for (domain = domain_list(); domain; domain = domain->next) {
00971                 if (domain->primary) {
00972                         primary_domain = domain;
00973                 }
00974                 if ((domain != child->domain) && !domain->primary) {
00975                         TALLOC_FREE(domain->check_online_event);
00976                 }
00977         }
00978 
00979         /* Ensure we're not handling an event inherited from
00980            our parent. */
00981 
00982         cancel_named_event(winbind_event_context(),
00983                            "krb5_ticket_refresh_handler");
00984 
00985         /* We might be in the idmap child...*/
00986         if (child->domain && !(child->domain->internal) &&
00987             lp_winbind_offline_logon()) {
00988 
00989                 set_domain_online_request(child->domain);
00990 
00991                 if (primary_domain != child->domain) {
00992                         /* We need to talk to the primary
00993                          * domain as well as the trusted
00994                          * domain inside a trusted domain
00995                          * child.
00996                          * See the code in :
00997                          * winbindd_dual_pam_auth_samlogon()
00998                          * especially the calling of 
00999                          * contact_domain = find_our_domain()
01000                          * in the non-DC case for details.
01001                          */
01002                         set_domain_online_request(primary_domain);
01003                 }
01004 
01005                 child->lockout_policy_event = event_add_timed(
01006                         winbind_event_context(), NULL, timeval_zero(),
01007                         "account_lockout_policy_handler",
01008                         account_lockout_policy_handler,
01009                         child);
01010         }
01011 
01012         while (1) {
01013 
01014                 int ret;
01015                 fd_set read_fds;
01016                 struct timeval t;
01017                 struct timeval *tp;
01018                 struct timeval now;
01019 
01020                 /* free up any talloc memory */
01021                 lp_TALLOC_FREE();
01022                 main_loop_TALLOC_FREE();
01023 
01024                 /* check for signals */
01025                 winbind_check_sigterm(false);
01026                 winbind_check_sighup(override_logfile ? NULL :
01027                         child->logfilename);
01028 
01029                 run_events(winbind_event_context(), 0, NULL, NULL);
01030 
01031                 GetTimeOfDay(&now);
01032 
01033                 if (child->domain && child->domain->startup &&
01034                                 (now.tv_sec > child->domain->startup_time + 30)) {
01035                         /* No longer in "startup" mode. */
01036                         DEBUG(10,("fork_domain_child: domain %s no longer in 'startup' mode.\n",
01037                                 child->domain->name ));
01038                         child->domain->startup = False;
01039                 }
01040 
01041                 tp = get_timed_events_timeout(winbind_event_context(), &t);
01042                 if (tp) {
01043                         DEBUG(11,("select will use timeout of %u.%u seconds\n",
01044                                 (unsigned int)tp->tv_sec, (unsigned int)tp->tv_usec ));
01045                 }
01046 
01047                 /* Handle messages */
01048 
01049                 message_dispatch();
01050 
01051                 FD_ZERO(&read_fds);
01052                 FD_SET(state.sock, &read_fds);
01053 
01054                 ret = sys_select(state.sock + 1, &read_fds, NULL, NULL, tp);
01055 
01056                 if (ret == 0) {
01057                         DEBUG(11,("nothing is ready yet, continue\n"));
01058                         continue;
01059                 }
01060 
01061                 if (ret == -1 && errno == EINTR) {
01062                         /* We got a signal - continue. */
01063                         continue;
01064                 }
01065 
01066                 if (ret == -1 && errno != EINTR) {
01067                         DEBUG(0,("select error occured\n"));
01068                         perror("select");
01069                         return False;
01070                 }
01071 
01072                 /* fetch a request from the main daemon */
01073                 child_read_request(&state);
01074 
01075                 if (state.finished) {
01076                         /* we lost contact with our parent */
01077                         exit(0);
01078                 }
01079 
01080                 DEBUG(4,("child daemon request %d\n", (int)state.request.cmd));
01081 
01082                 ZERO_STRUCT(state.response);
01083                 state.request.null_term = '\0';
01084                 child_process_request(child->domain, &state);
01085 
01086                 SAFE_FREE(state.request.extra_data.data);
01087 
01088                 cache_store_response(sys_getpid(), &state.response);
01089 
01090                 SAFE_FREE(state.response.extra_data.data);
01091 
01092                 /* We just send the result code back, the result
01093                  * structure needs to be fetched via the
01094                  * winbindd_cache. Hmm. That needs fixing... */
01095 
01096                 if (write_data(state.sock,
01097                                (const char *)&state.response.result,
01098                                sizeof(state.response.result)) !=
01099                     sizeof(state.response.result)) {
01100                         DEBUG(0, ("Could not write result\n"));
01101                         exit(1);
01102                 }
01103         }
01104 }

static void domain_init_recv ( void *  private_data_data,
BOOL  success 
) [static]

winbindd_dual.c395 行で定義されています。

参照先 async_request()winbindd_domain::childdomain_request_state::continuationdomain_request_state::domaindomain_request_state::mem_ctxdomain_request_state::private_data_datadomain_request_state::requestdomain_request_state::response.

参照元 async_domain_request().

00396 {
00397         struct domain_request_state *state =
00398                 talloc_get_type_abort(private_data_data, struct domain_request_state);
00399 
00400         if (!success) {
00401                 DEBUG(5, ("Domain init returned an error\n"));
00402                 state->continuation(state->private_data_data, False);
00403                 return;
00404         }
00405 
00406         async_request(state->mem_ctx, &state->domain->child,
00407                       state->request, state->response,
00408                       state->continuation, state->private_data_data);
00409 }

void async_domain_request ( TALLOC_CTX mem_ctx,
struct winbindd_domain domain,
struct winbindd_request request,
struct winbindd_response response,
void(*)(void *private_data_data, BOOL success)  continuation,
void *  private_data_data 
)

winbindd_dual.c328 行で定義されています。

参照先 async_request()winbindd_domain::childdomain_request_state::continuationdomain_request_state::domaindomain_init_recv()init_child_connection()winbindd_domain::initializeddomain_request_state::mem_ctxdomain_request_state::private_data_datadomain_request_state::requestdomain_request_state::response.

参照元 add_trusted_domains()do_async_domain()init_child_connection()sendto_domain()sequence_recv()winbindd_show_sequence().

00334 {
00335         struct domain_request_state *state;
00336 
00337         if (domain->initialized) {
00338                 async_request(mem_ctx, &domain->child, request, response,
00339                               continuation, private_data_data);
00340                 return;
00341         }
00342 
00343         state = TALLOC_P(mem_ctx, struct domain_request_state);
00344         if (state == NULL) {
00345                 DEBUG(0, ("talloc failed\n"));
00346                 continuation(private_data_data, False);
00347                 return;
00348         }
00349 
00350         state->mem_ctx = mem_ctx;
00351         state->domain = domain;
00352         state->request = request;
00353         state->response = response;
00354         state->continuation = continuation;
00355         state->private_data_data = private_data_data;
00356 
00357         init_child_connection(domain, domain_init_recv, state);
00358 }

static void recvfrom_child ( void *  private_data_data,
BOOL  success 
) [static]

winbindd_dual.c360 行で定義されています。

参照先 request_error()request_ok()winbindd_cli_state::responsewinbindd_response::resultresultWINBINDD_OKWINBINDD_PENDING.

参照元 sendto_child()sendto_domain().

00361 {
00362         struct winbindd_cli_state *state =
00363                 talloc_get_type_abort(private_data_data, struct winbindd_cli_state);
00364         enum winbindd_result result = state->response.result;
00365 
00366         /* This is an optimization: The child has written directly to the
00367          * response buffer. The request itself is still in pending state,
00368          * state that in the result code. */
00369 
00370         state->response.result = WINBINDD_PENDING;
00371 
00372         if ((!success) || (result != WINBINDD_OK)) {
00373                 request_error(state);
00374                 return;
00375         }
00376 
00377         request_ok(state);
00378 }

void sendto_child ( struct winbindd_cli_state state,
struct winbindd_child child 
)

winbindd_dual.c380 行で定義されています。

参照先 async_request()winbindd_cli_state::mem_ctxrecvfrom_child()winbindd_cli_state::requestwinbindd_cli_state::response.

参照元 winbindd_allocate_gid()winbindd_allocate_uid().

00382 {
00383         async_request(state->mem_ctx, child, &state->request,
00384                       &state->response, recvfrom_child, state);
00385 }

void sendto_domain ( struct winbindd_cli_state state,
struct winbindd_domain domain 
)

winbindd_dual.c387 行で定義されています。

参照先 async_domain_request()winbindd_cli_state::mem_ctxrecvfrom_child()winbindd_cli_state::requestwinbindd_cli_state::response.

参照元 winbindd_ccache_ntlm_auth()winbindd_check_machine_acct()winbindd_getdcname()winbindd_getuserdomgroups()winbindd_list_trusted_domains()winbindd_lookuprids()winbindd_pam_auth()winbindd_pam_auth_crap()winbindd_pam_chauthtok()winbindd_pam_chng_pswd_auth_crap()winbindd_pam_logoff()winbindd_show_sequence().

00389 {
00390         async_domain_request(state->mem_ctx, domain,
00391                              &state->request, &state->response,
00392                              recvfrom_child, state);
00393 }

static void child_process_request ( struct winbindd_domain domain,
struct winbindd_cli_state state 
) [static]

winbindd_dual.c458 行で定義されています。

参照先 child_dispatch_tablewinbindd_child_dispatch_table::cmdwinbindd_request::cmdwinbindd_child_dispatch_table::fnwinbindd_response::lengthwinbindd_cli_state::mem_ctxwinbindd_cli_state::requestwinbindd_cli_state::responsewinbindd_response::resulttalloc_init()winbindd_child_dispatch_table::winbindd_cmd_nameWINBINDD_ERROR.

00460 {
00461         struct winbindd_child_dispatch_table *table;
00462 
00463         /* Free response data - we may be interrupted and receive another
00464            command before being able to send this data off. */
00465 
00466         state->response.result = WINBINDD_ERROR;
00467         state->response.length = sizeof(struct winbindd_response);
00468 
00469         state->mem_ctx = talloc_init("winbind request");
00470         if (state->mem_ctx == NULL)
00471                 return;
00472 
00473         /* Process command */
00474 
00475         for (table = child_dispatch_table; table->fn; table++) {
00476                 if (state->request.cmd == table->cmd) {
00477                         DEBUG(10,("process_request: request fn %s\n",
00478                                   table->winbindd_cmd_name ));
00479                         state->response.result = table->fn(domain, state);
00480                         break;
00481                 }
00482         }
00483 
00484         if (!table->fn) {
00485                 DEBUG(10,("process_request: unknown request fn number %d\n",
00486                           (int)state->request.cmd ));
00487                 state->response.result = WINBINDD_ERROR;
00488         }
00489 
00490         talloc_destroy(state->mem_ctx);
00491 }

void setup_domain_child ( struct winbindd_domain domain,
struct winbindd_child child,
const char *  explicit_logfile 
)

winbindd_dual.c493 行で定義されています。

参照先 winbindd_child::domaindyn_LOGFILEBASEwinbindd_child::logfilenamewinbindd_domain::namepstr_sprintf()smb_panic().

参照元 init_domain_list()init_idmap_child()trustdom_recv().

00496 {
00497         if (explicit_logfile != NULL) {
00498                 pstr_sprintf(child->logfilename, "%s/winbindd-%s.log",
00499                              dyn_LOGFILEBASE, explicit_logfile);
00500         } else if (domain != NULL) {
00501                 pstr_sprintf(child->logfilename, "%s/wb-%s.log",
00502                              dyn_LOGFILEBASE, domain->name);
00503         } else {
00504                 smb_panic("Internal error: domain == NULL && "
00505                           "explicit_logfile == NULL");
00506         }
00507 
00508         child->domain = domain;
00509 }

void winbind_child_died ( pid_t  pid  ) 

winbindd_dual.c513 行で定義されています。

参照先 childrenwinbindd_child::nextwinbindd_child::pid.

参照元 async_request_fail().

00514 {
00515         struct winbindd_child *child;
00516 
00517         for (child = children; child != NULL; child = child->next) {
00518                 if (child->pid == pid) {
00519                         break;
00520                 }
00521         }
00522 
00523         if (child == NULL) {
00524                 DEBUG(5, ("Already reaped child %u died\n", (unsigned int)pid));
00525                 return;
00526         }
00527 
00528         /* This will be re-added in fork_domain_child() */
00529 
00530         DLIST_REMOVE(children, child);
00531         
00532         remove_fd_event(&child->event);
00533         close(child->event.fd);
00534         child->event.fd = 0;
00535         child->event.flags = 0;
00536         child->pid = 0;
00537 
00538         schedule_async_request(child);
00539 }

void winbindd_flush_negative_conn_cache ( struct winbindd_domain domain  ) 

winbindd_dual.c543 行で定義されています。

参照先 winbindd_domain::alt_namewinbindd_child::domainflush_negative_conn_cache_for_domain()winbindd_domain::name.

参照元 child_msg_online()winbind_msg_online()winbindd_dual_pam_auth().

void winbind_msg_offline ( int  msg_type,
struct process_id  src,
void *  buf,
size_t  len,
void *  private_data 
)

winbindd_dual.c553 行で定義されています。

参照先 winbindd_child::domaindomain_list()idmap_child()winbindd_domain::internalmessage_send_pid()winbindd_domain::namewinbindd_domain::nextwinbindd_child::pidpid_to_procid()winbindd_domain::primaryset_domain_offline()set_global_winbindd_state_offline().

参照元 main().

00555 {
00556         struct winbindd_child *child;
00557         struct winbindd_domain *domain;
00558 
00559         DEBUG(10,("winbind_msg_offline: got offline message.\n"));
00560 
00561         if (!lp_winbind_offline_logon()) {
00562                 DEBUG(10,("winbind_msg_offline: rejecting offline message.\n"));
00563                 return;
00564         }
00565 
00566         /* Set our global state as offline. */
00567         if (!set_global_winbindd_state_offline()) {
00568                 DEBUG(10,("winbind_msg_offline: offline request failed.\n"));
00569                 return;
00570         }
00571 
00572         /* Set all our domains as offline. */
00573         for (domain = domain_list(); domain; domain = domain->next) {
00574                 if (domain->internal) {
00575                         continue;
00576                 }
00577                 DEBUG(5,("winbind_msg_offline: marking %s offline.\n", domain->name));
00578                 set_domain_offline(domain);
00579 
00580                 /* Send an offline message to the idmap child when our
00581                    primary domain goes offline */
00582 
00583                 if ( domain->primary ) {
00584                         struct winbindd_child *idmap = idmap_child();
00585 
00586                         if ( idmap->pid != 0 ) {
00587                                 message_send_pid(pid_to_procid(idmap->pid), 
00588                                                  MSG_WINBIND_OFFLINE, 
00589                                                  domain->name, 
00590                                                  strlen(domain->name)+1, 
00591                                                  False);
00592                         }                       
00593                 }
00594         }
00595 
00596         for (child = children; child != NULL; child = child->next) {
00597                 /* Don't send message to idmap child.  We've already
00598                    done so above. */
00599                 if (!child->domain || (child == idmap_child())) {
00600                         continue;
00601                 }
00602 
00603                 /* Or internal domains (this should not be possible....) */
00604                 if (child->domain->internal) {
00605                         continue;
00606                 }
00607 
00608                 /* Each winbindd child should only process requests for one domain - make sure
00609                    we only set it online / offline for that domain. */
00610 
00611                 DEBUG(10,("winbind_msg_offline: sending message to pid %u for domain %s.\n",
00612                         (unsigned int)child->pid, domain->name ));
00613 
00614                 message_send_pid(pid_to_procid(child->pid), MSG_WINBIND_OFFLINE, child->domain->name,
00615                         strlen(child->domain->name)+1, False);
00616         }
00617 }

void winbind_msg_online ( int  msg_type,
struct process_id  src,
void *  buf,
size_t  len,
void *  private_data 
)

winbindd_dual.c621 行で定義されています。

参照先 winbindd_child::domaindomain_list()idmap_child()winbindd_domain::internalmessage_send_pid()winbindd_domain::namewinbindd_domain::nextwinbindd_child::pidpid_to_procid()winbindd_domain::primaryset_domain_online_request()set_global_winbindd_state_online()smb_nscd_flush_group_cache()smb_nscd_flush_user_cache()winbindd_flush_negative_conn_cache().

参照元 main().

00623 {
00624         struct winbindd_child *child;
00625         struct winbindd_domain *domain;
00626 
00627         DEBUG(10,("winbind_msg_online: got online message.\n"));
00628 
00629         if (!lp_winbind_offline_logon()) {
00630                 DEBUG(10,("winbind_msg_online: rejecting online message.\n"));
00631                 return;
00632         }
00633 
00634         /* Set our global state as online. */
00635         set_global_winbindd_state_online();
00636 
00637         smb_nscd_flush_user_cache();
00638         smb_nscd_flush_group_cache();
00639 
00640         /* Set all our domains as online. */
00641         for (domain = domain_list(); domain; domain = domain->next) {
00642                 if (domain->internal) {
00643                         continue;
00644                 }
00645                 DEBUG(5,("winbind_msg_online: requesting %s to go online.\n", domain->name));
00646 
00647                 winbindd_flush_negative_conn_cache(domain);
00648                 set_domain_online_request(domain);
00649 
00650                 /* Send an online message to the idmap child when our
00651                    primary domain comes back online */
00652 
00653                 if ( domain->primary ) {
00654                         struct winbindd_child *idmap = idmap_child();
00655                         
00656                         if ( idmap->pid != 0 ) {
00657                                 message_send_pid(pid_to_procid(idmap->pid), 
00658                                                  MSG_WINBIND_ONLINE,
00659                                                  domain->name,
00660                                                  strlen(domain->name)+1, 
00661                                                  False);
00662                         }
00663                         
00664                 }
00665         }
00666 
00667         for (child = children; child != NULL; child = child->next) {
00668                 /* Don't send message to idmap child. */
00669                 if (!child->domain || (child == idmap_child())) {
00670                         continue;
00671                 }
00672 
00673                 /* Or internal domains (this should not be possible....) */
00674                 if (child->domain->internal) {
00675                         continue;
00676                 }
00677 
00678                 /* Each winbindd child should only process requests for one domain - make sure
00679                    we only set it online / offline for that domain. */
00680 
00681                 DEBUG(10,("winbind_msg_online: sending message to pid %u for domain %s.\n",
00682                         (unsigned int)child->pid, child->domain->name ));
00683 
00684                 message_send_pid(pid_to_procid(child->pid), MSG_WINBIND_ONLINE, child->domain->name,
00685                         strlen(child->domain->name)+1, False);
00686         }
00687 }

void winbind_msg_onlinestatus ( int  msg_type,
struct process_id  src,
void *  buf,
size_t  len,
void *  private_data 
)

winbindd_dual.c690 行で定義されています。

参照先 childrenwinbindd_child::domainmessage_send_pid()winbindd_child::nextwinbindd_child::pidpid_to_procid()winbindd_domain::primary.

参照元 main().

00692 {
00693         struct winbindd_child *child;
00694 
00695         DEBUG(10,("winbind_msg_onlinestatus: got onlinestatus message.\n"));
00696 
00697         for (child = children; child != NULL; child = child->next) {
00698                 if (child->domain && child->domain->primary) {
00699                         DEBUG(10,("winbind_msg_onlinestatus: "
00700                                   "sending message to pid %u of primary domain.\n",
00701                                   (unsigned int)child->pid));
00702                         message_send_pid(pid_to_procid(child->pid), 
00703                                          MSG_WINBIND_ONLINESTATUS, buf, len, False);
00704                         break;
00705                 }
00706         }
00707 }

static void account_lockout_policy_handler ( struct event_context ctx,
struct timed_event te,
const struct timeval *  now,
void *  private_data 
) [static]

winbindd_dual.c710 行で定義されています。

参照先 winbindd_child::domainevent_add_timed()lockout_policy()winbindd_child::lockout_policy_eventwinbindd_domain::methodsmethodsnt_errstr()resulttalloc_init()timeval_current_ofs()winbind_event_context().

00714 {
00715         struct winbindd_child *child =
00716                 (struct winbindd_child *)private_data;
00717         TALLOC_CTX *mem_ctx = NULL;
00718         struct winbindd_methods *methods;
00719         SAM_UNK_INFO_12 lockout_policy;
00720         NTSTATUS result;
00721 
00722         DEBUG(10,("account_lockout_policy_handler called\n"));
00723 
00724         TALLOC_FREE(child->lockout_policy_event);
00725 
00726         methods = child->domain->methods;
00727 
00728         mem_ctx = talloc_init("account_lockout_policy_handler ctx");
00729         if (!mem_ctx) {
00730                 result = NT_STATUS_NO_MEMORY;
00731         } else {
00732                 result = methods->lockout_policy(child->domain, mem_ctx, &lockout_policy);
00733         }
00734 
00735         talloc_destroy(mem_ctx);
00736 
00737         if (!NT_STATUS_IS_OK(result)) {
00738                 DEBUG(10,("account_lockout_policy_handler: lockout_policy failed error %s\n",
00739                          nt_errstr(result)));
00740         }
00741 
00742         child->lockout_policy_event = event_add_timed(winbind_event_context(), NULL,
00743                                                       timeval_current_ofs(3600, 0),
00744                                                       "account_lockout_policy_handler",
00745                                                       account_lockout_policy_handler,
00746                                                       child);
00747 }

static void child_msg_offline ( int  msg_type,
struct process_id  src,
void *  buf,
size_t  len,
void *  private_data 
) [static]

winbindd_dual.c751 行で定義されています。

参照先 domain_list()winbindd_domain::internalwinbindd_domain::namewinbindd_domain::nextset_domain_offline()set_global_winbindd_state_offline()strequal().

参照元 fork_domain_child().

00753 {
00754         struct winbindd_domain *domain;
00755         const char *domainname = (const char *)buf;
00756 
00757         if (buf == NULL || len == 0) {
00758                 return;
00759         }
00760 
00761         DEBUG(5,("child_msg_offline received for domain %s.\n", domainname));
00762 
00763         if (!lp_winbind_offline_logon()) {
00764                 DEBUG(10,("child_msg_offline: rejecting offline message.\n"));
00765                 return;
00766         }
00767 
00768         /* Set our global state as offline. */
00769         if (!set_global_winbindd_state_offline()) {
00770                 DEBUG(10,("child_msg_offline: offline request failed.\n"));
00771                 return;
00772         }
00773 
00774         /* Mark the requested domain offline. */
00775 
00776         for (domain = domain_list(); domain; domain = domain->next) {
00777                 if (domain->internal) {
00778                         continue;
00779                 }
00780                 if (strequal(domain->name, domainname)) {
00781                         DEBUG(5,("child_msg_offline: marking %s offline.\n", domain->name));
00782                         set_domain_offline(domain);
00783                 }
00784         }
00785 }

static void child_msg_online ( int  msg_type,
struct process_id  src,
void *  buf,
size_t  len,
void *  private_data 
) [static]

winbindd_dual.c789 行で定義されています。

参照先 domain_list()winbindd_domain::internalwinbindd_domain::namewinbindd_domain::nextset_domain_online_request()set_global_winbindd_state_online()strequal()winbindd_flush_negative_conn_cache().

参照元 fork_domain_child().

00791 {
00792         struct winbindd_domain *domain;
00793         const char *domainname = (const char *)buf;
00794 
00795         if (buf == NULL || len == 0) {
00796                 return;
00797         }
00798 
00799         DEBUG(5,("child_msg_online received for domain %s.\n", domainname));
00800 
00801         if (!lp_winbind_offline_logon()) {
00802                 DEBUG(10,("child_msg_online: rejecting online message.\n"));
00803                 return;
00804         }
00805 
00806         /* Set our global state as online. */
00807         set_global_winbindd_state_online();
00808 
00809         /* Try and mark everything online - delete any negative cache entries
00810            to force a reconnect now. */
00811 
00812         for (domain = domain_list(); domain; domain = domain->next) {
00813                 if (domain->internal) {
00814                         continue;
00815                 }
00816                 if (strequal(domain->name, domainname)) {
00817                         DEBUG(5,("child_msg_online: requesting %s to go online.\n", domain->name));
00818                         winbindd_flush_negative_conn_cache(domain);
00819                         set_domain_online_request(domain);
00820                 }
00821         }
00822 }

static const char* collect_onlinestatus ( TALLOC_CTX mem_ctx  )  [static]

winbindd_dual.c824 行で定義されています。

参照先 bufdomain_list()get_global_winbindd_state_offline()winbindd_domain::namewinbindd_domain::nextwinbindd_domain::onlinetalloc_asprintf()talloc_asprintf_append().

参照元 child_msg_onlinestatus().

00825 {
00826         struct winbindd_domain *domain;
00827         char *buf = NULL;
00828 
00829         if ((buf = talloc_asprintf(mem_ctx, "global:%s ", 
00830                                    get_global_winbindd_state_offline() ? 
00831                                    "Offline":"Online")) == NULL) {
00832                 return NULL;
00833         }
00834 
00835         for (domain = domain_list(); domain; domain = domain->next) {
00836                 if ((buf = talloc_asprintf_append(buf, "%s:%s ", 
00837                                                   domain->name, 
00838                                                   domain->online ?
00839                                                   "Online":"Offline")) == NULL) {
00840                         return NULL;
00841                 }
00842         }
00843 
00844         buf = talloc_asprintf_append(buf, "\n");
00845 
00846         DEBUG(5,("collect_onlinestatus: %s", buf));
00847 
00848         return buf;
00849 }

static void child_msg_onlinestatus ( int  msg_type,
struct process_id  src,
void *  buf,
size_t  len,
void *  private_data 
) [static]

winbindd_dual.c851 行で定義されています。

参照先 collect_onlinestatus()messagemessage_send_pid()talloc_init().

参照元 fork_domain_child().

00853 {
00854         TALLOC_CTX *mem_ctx;
00855         const char *message;
00856         struct process_id *sender;
00857         
00858         DEBUG(5,("winbind_msg_onlinestatus received.\n"));
00859 
00860         if (!buf) {
00861                 return;
00862         }
00863 
00864         sender = (struct process_id *)buf;
00865 
00866         mem_ctx = talloc_init("winbind_msg_onlinestatus");
00867         if (mem_ctx == NULL) {
00868                 return;
00869         }
00870         
00871         message = collect_onlinestatus(mem_ctx);
00872         if (message == NULL) {
00873                 talloc_destroy(mem_ctx);
00874                 return;
00875         }
00876 
00877         message_send_pid(*sender, MSG_WINBIND_ONLINESTATUS, 
00878                          message, strlen(message) + 1, True);
00879 
00880         talloc_destroy(mem_ctx);
00881 }


変数

BOOL override_logfile

debug.c91 行で定義されています。

struct winbindd_child_dispatch_table child_dispatch_table[] [static]

winbindd_dual.c418 行で定義されています。

参照元 child_process_request().

struct winbindd_child* children = NULL

winbindd_dual.c511 行で定義されています。

参照元 add_child_pid()fork_domain_child()remove_child_pid()winbind_child_died()winbind_msg_onlinestatus().


Sambaに対してSat Aug 29 21:23:57 2009に生成されました。  doxygen 1.4.7