authd: assume all providers are running
Otherwise ident returns without setting itself running causing problems. Move opm/blacklist before ident/rdns so that they can receive completion notifications.
This commit is contained in:
parent
ffd0a904d9
commit
f21ef0cebc
6 changed files with 36 additions and 35 deletions
|
@ -62,6 +62,29 @@ static rb_dlink_list free_pids;
|
||||||
static uint32_t allocated_pids;
|
static uint32_t allocated_pids;
|
||||||
static struct ev_entry *timeout_ev;
|
static struct ev_entry *timeout_ev;
|
||||||
|
|
||||||
|
/* Set a provider's raw status */
|
||||||
|
static inline void
|
||||||
|
set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status)
|
||||||
|
{
|
||||||
|
auth->data[provider].status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the provider as running */
|
||||||
|
static inline void
|
||||||
|
set_provider_running(struct auth_client *auth, uint32_t provider)
|
||||||
|
{
|
||||||
|
auth->providers_active++;
|
||||||
|
set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Provider is no longer operating on this auth client */
|
||||||
|
static inline void
|
||||||
|
set_provider_done(struct auth_client *auth, uint32_t provider)
|
||||||
|
{
|
||||||
|
set_provider_status(auth, provider, PROVIDER_STATUS_DONE);
|
||||||
|
auth->providers_active--;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initalise all providers */
|
/* Initalise all providers */
|
||||||
void
|
void
|
||||||
init_providers(void)
|
init_providers(void)
|
||||||
|
@ -69,10 +92,13 @@ init_providers(void)
|
||||||
auth_clients = rb_dictionary_create("pending auth clients", rb_uint32cmp);
|
auth_clients = rb_dictionary_create("pending auth clients", rb_uint32cmp);
|
||||||
timeout_ev = rb_event_addish("provider_timeout_event", provider_timeout_event, NULL, 1);
|
timeout_ev = rb_event_addish("provider_timeout_event", provider_timeout_event, NULL, 1);
|
||||||
|
|
||||||
load_provider(&rdns_provider);
|
/* FIXME must be started before rdns/ident to receive completion notification from them */
|
||||||
load_provider(&ident_provider);
|
|
||||||
load_provider(&blacklist_provider);
|
load_provider(&blacklist_provider);
|
||||||
load_provider(&opm_provider);
|
load_provider(&opm_provider);
|
||||||
|
|
||||||
|
/* FIXME must be started after blacklist/opm in case of early completion notifications */
|
||||||
|
load_provider(&rdns_provider);
|
||||||
|
load_provider(&ident_provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate all providers */
|
/* Terminate all providers */
|
||||||
|
@ -314,6 +340,7 @@ start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_
|
||||||
lrb_assert(provider->start != NULL);
|
lrb_assert(provider->start != NULL);
|
||||||
|
|
||||||
/* Execute providers */
|
/* Execute providers */
|
||||||
|
set_provider_running(auth, provider->id);
|
||||||
if(!provider->start(auth))
|
if(!provider->start(auth))
|
||||||
/* Rejected immediately */
|
/* Rejected immediately */
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -177,31 +177,6 @@ get_provider_status(struct auth_client *auth, uint32_t provider)
|
||||||
return auth->data[provider].status;
|
return auth->data[provider].status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a provider's raw status */
|
|
||||||
static inline void
|
|
||||||
set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status)
|
|
||||||
{
|
|
||||||
auth->data[provider].status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the provider as running
|
|
||||||
* If you're doing asynchronous work call this */
|
|
||||||
static inline void
|
|
||||||
set_provider_running(struct auth_client *auth, uint32_t provider)
|
|
||||||
{
|
|
||||||
auth->providers_active++;
|
|
||||||
set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Provider is no longer operating on this auth client
|
|
||||||
* You should use provider_done and not this */
|
|
||||||
static inline void
|
|
||||||
set_provider_done(struct auth_client *auth, uint32_t provider)
|
|
||||||
{
|
|
||||||
set_provider_status(auth, provider, PROVIDER_STATUS_DONE);
|
|
||||||
auth->providers_active--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if provider is operating on this auth client */
|
/* Check if provider is operating on this auth client */
|
||||||
static inline bool
|
static inline bool
|
||||||
is_provider_running(struct auth_client *auth, uint32_t provider)
|
is_provider_running(struct auth_client *auth, uint32_t provider)
|
||||||
|
|
|
@ -369,9 +369,11 @@ blacklists_start(struct auth_client *auth)
|
||||||
|
|
||||||
lrb_assert(get_provider_data(auth, SELF_PID) == NULL);
|
lrb_assert(get_provider_data(auth, SELF_PID) == NULL);
|
||||||
|
|
||||||
if(!rb_dlink_list_length(&blacklist_list))
|
if(!rb_dlink_list_length(&blacklist_list)) {
|
||||||
/* Nothing to do... */
|
/* Nothing to do... */
|
||||||
|
provider_done(auth, SELF_PID);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
auth_client_ref(auth);
|
auth_client_ref(auth);
|
||||||
|
|
||||||
|
@ -388,7 +390,6 @@ blacklists_start(struct auth_client *auth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_provider_running(auth, SELF_PID);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ ident_start(struct auth_client *auth)
|
||||||
{
|
{
|
||||||
rb_free(query);
|
rb_free(query);
|
||||||
notice_client(auth->cid, messages[REPORT_DISABLED]);
|
notice_client(auth->cid, messages[REPORT_DISABLED]);
|
||||||
set_provider_done(auth, SELF_PID);
|
provider_done(auth, SELF_PID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,8 +329,6 @@ ident_start(struct auth_client *auth)
|
||||||
ident_connected,
|
ident_connected,
|
||||||
auth, ident_timeout);
|
auth, ident_timeout);
|
||||||
|
|
||||||
set_provider_running(auth, SELF_PID);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -619,9 +619,11 @@ opm_start(struct auth_client *auth)
|
||||||
|
|
||||||
lrb_assert(get_provider_data(auth, SELF_PID) == NULL);
|
lrb_assert(get_provider_data(auth, SELF_PID) == NULL);
|
||||||
|
|
||||||
if(!opm_enable || rb_dlink_list_length(&proxy_scanners) == 0)
|
if(!opm_enable || rb_dlink_list_length(&proxy_scanners) == 0) {
|
||||||
/* Nothing to do... */
|
/* Nothing to do... */
|
||||||
|
provider_done(auth, SELF_PID);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
auth_client_ref(auth);
|
auth_client_ref(auth);
|
||||||
|
|
||||||
|
@ -634,7 +636,6 @@ opm_start(struct auth_client *auth)
|
||||||
opm_scan(auth);
|
opm_scan(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_provider_running(auth, SELF_PID);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,6 @@ rdns_start(struct auth_client *auth)
|
||||||
query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth);
|
query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth);
|
||||||
|
|
||||||
notice_client(auth->cid, messages[REPORT_LOOKUP]);
|
notice_client(auth->cid, messages[REPORT_LOOKUP]);
|
||||||
set_provider_running(auth, SELF_PID);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue