authd/provider: do not accept clients until all providers have had a chance to run

This commit is contained in:
Elizabeth Myers 2016-03-26 20:32:35 -05:00
parent f5586c3abb
commit 05fdc0301d

View file

@ -153,7 +153,8 @@ void provider_done(struct auth_client *auth, provider_t id)
if(!auth->providers) if(!auth->providers)
{ {
/* No more providers, done */ if(!auth->providers_starting)
/* Only do this when there are no providers left */
accept_client(auth, 0); accept_client(auth, 0);
return; return;
} }
@ -223,6 +224,15 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co
auth->cid = (uint32_t)lcid; auth->cid = (uint32_t)lcid;
if(rb_dictionary_find(auth_clients, RB_UINT_TO_POINTER(auth->cid)) == NULL)
rb_dictionary_add(auth_clients, RB_UINT_TO_POINTER(auth->cid), auth);
else
{
warn_opers(L_CRIT, "BUG: duplicate client added via start_auth: %x", auth->cid);
rb_free(auth);
return;
}
rb_strlcpy(auth->l_ip, l_ip, sizeof(auth->l_ip)); rb_strlcpy(auth->l_ip, l_ip, sizeof(auth->l_ip));
auth->l_port = (uint16_t)atoi(l_port); /* should be safe */ auth->l_port = (uint16_t)atoi(l_port); /* should be safe */
(void) rb_inet_pton_sock(l_ip, (struct sockaddr *)&auth->l_addr); (void) rb_inet_pton_sock(l_ip, (struct sockaddr *)&auth->l_addr);
@ -247,12 +257,13 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co
memset(auth->data, 0, sizeof(auth->data)); memset(auth->data, 0, sizeof(auth->data));
rb_dictionary_add(auth_clients, RB_UINT_TO_POINTER(auth->cid), auth); auth->providers_starting = true;
RB_DLINK_FOREACH(ptr, auth_providers.head) RB_DLINK_FOREACH(ptr, auth_providers.head)
{ {
provider = ptr->data; provider = ptr->data;
lrb_assert(provider->start != NULL);
/* Execute providers */ /* Execute providers */
if(!provider->start(auth)) if(!provider->start(auth))
{ {
@ -261,6 +272,7 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co
return; return;
} }
} }
auth->providers_starting = false;
/* If no providers are running, accept the client */ /* If no providers are running, accept the client */
if(!auth->providers) if(!auth->providers)