From 05fdc0301d415d5422f07d87d912036ea2ad8ec3 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Sat, 26 Mar 2016 20:32:35 -0500 Subject: [PATCH] authd/provider: do not accept clients until all providers have had a chance to run --- authd/provider.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/authd/provider.c b/authd/provider.c index c92fea26a..471e20d7a 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -153,8 +153,9 @@ void provider_done(struct auth_client *auth, provider_t id) if(!auth->providers) { - /* No more providers, done */ - accept_client(auth, 0); + if(!auth->providers_starting) + /* Only do this when there are no providers left */ + accept_client(auth, 0); 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; + 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)); auth->l_port = (uint16_t)atoi(l_port); /* should be safe */ (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)); - rb_dictionary_add(auth_clients, RB_UINT_TO_POINTER(auth->cid), auth); - + auth->providers_starting = true; RB_DLINK_FOREACH(ptr, auth_providers.head) { provider = ptr->data; + lrb_assert(provider->start != NULL); + /* Execute providers */ 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; } } + auth->providers_starting = false; /* If no providers are running, accept the client */ if(!auth->providers)