authd: update all providers to new timeout API

This commit is contained in:
Elizabeth Myers 2016-04-04 04:32:55 -05:00
parent 2e1e0b9981
commit bdddd9ba83
4 changed files with 25 additions and 22 deletions

View file

@ -261,7 +261,7 @@ blacklist_dns_callback(const char *result, bool status, query_type type, void *d
rb_dlink_list_length(&blacklist_list) > 1 ? "s" : "");
rb_free(bluser);
set_provider_data(auth, PROVIDER_BLACKLIST, NULL);
auth->timeout[PROVIDER_BLACKLIST] = 0;
set_provider_timeout_absolute(auth, PROVIDER_BLACKLIST, 0);
provider_done(auth, PROVIDER_BLACKLIST);
}
}
@ -311,7 +311,7 @@ lookup_all_blacklists(struct auth_client *auth)
initiate_blacklist_dnsquery(bl, auth);
}
auth->timeout[PROVIDER_BLACKLIST] = rb_current_time() + blacklist_timeout;
set_provider_timeout_relative(auth, PROVIDER_BLACKLIST, blacklist_timeout);
}
static inline void
@ -407,7 +407,7 @@ blacklists_cancel(struct auth_client *auth)
rb_free(bluser);
set_provider_data(auth, PROVIDER_BLACKLIST, NULL);
auth->timeout[PROVIDER_BLACKLIST] = 0;
set_provider_timeout_absolute(auth, PROVIDER_BLACKLIST, 0);
provider_done(auth, PROVIDER_BLACKLIST);
}

View file

@ -181,7 +181,7 @@ client_fail(struct auth_client *auth, ident_message report)
rb_free(query);
set_provider_data(auth, PROVIDER_IDENT, NULL);
auth->timeout[PROVIDER_IDENT] = 0;
set_provider_timeout_absolute(auth, PROVIDER_IDENT, 0);
notice_client(auth->cid, messages[report]);
provider_done(auth, PROVIDER_IDENT);
@ -199,7 +199,7 @@ client_success(struct auth_client *auth)
rb_free(query);
set_provider_data(auth, PROVIDER_IDENT, NULL);
auth->timeout[PROVIDER_IDENT] = 0;
set_provider_timeout_absolute(auth, PROVIDER_IDENT, 0);
notice_client(auth->cid, messages[REPORT_FOUND]);
provider_done(auth, PROVIDER_IDENT);
@ -303,7 +303,7 @@ ident_start(struct auth_client *auth)
notice_client(auth->cid, messages[REPORT_LOOKUP]);
set_provider_data(auth, PROVIDER_IDENT, query);
auth->timeout[PROVIDER_IDENT] = rb_current_time() + ident_timeout;
set_provider_timeout_relative(auth, PROVIDER_IDENT, ident_timeout);
if((query->F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL)
{

View file

@ -618,7 +618,7 @@ opm_scan(struct auth_client *auth)
lrb_assert(auth != NULL);
lookup = get_provider_data(auth, PROVIDER_OPM);
auth->timeout[PROVIDER_OPM] = rb_current_time() + opm_timeout;
set_provider_timeout_relative(auth, PROVIDER_OPM, opm_timeout);
lookup->in_progress = true;
@ -695,7 +695,7 @@ opm_cancel(struct auth_client *auth)
rb_free(lookup);
set_provider_data(auth, PROVIDER_OPM, NULL);
auth->timeout[PROVIDER_OPM] = 0;
set_provider_timeout_absolute(auth, PROVIDER_OPM, 0);
provider_done(auth, PROVIDER_OPM);
}
}

View file

@ -58,9 +58,11 @@ static void
dns_answer_callback(const char *res, bool status, query_type type, void *data)
{
struct auth_client *auth = data;
struct user_query *query = auth->data[PROVIDER_RDNS];
struct user_query *query = get_provider_data(auth, PROVIDER_RDNS);
if(query == NULL || res == NULL || status == false)
lrb_assert(query != NULL);
if(res == NULL || status == false)
client_fail(auth, REPORT_FAIL);
else if(strlen(res) > HOSTLEN)
client_fail(auth, REPORT_TOOLONG);
@ -74,10 +76,9 @@ dns_answer_callback(const char *res, bool status, query_type type, void *data)
static void
client_fail(struct auth_client *auth, dns_message report)
{
struct user_query *query = auth->data[PROVIDER_RDNS];
struct user_query *query = get_provider_data(auth, PROVIDER_RDNS);
if(query == NULL)
return;
lrb_assert(query != NULL);
rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname));
@ -85,24 +86,26 @@ client_fail(struct auth_client *auth, dns_message report)
cancel_query(query->query);
rb_free(query);
auth->data[PROVIDER_RDNS] = NULL;
auth->timeout[PROVIDER_RDNS] = 0;
set_provider_data(auth, PROVIDER_RDNS, NULL);
set_provider_timeout_absolute(auth, PROVIDER_RDNS, 0);
provider_done(auth, PROVIDER_RDNS);
}
static void
client_success(struct auth_client *auth)
{
struct user_query *query = auth->data[PROVIDER_RDNS];
struct user_query *query = get_provider_data(auth, PROVIDER_RDNS);
lrb_assert(query != NULL);
notice_client(auth->cid, messages[REPORT_FOUND]);
cancel_query(query->query);
rb_free(query);
auth->data[PROVIDER_RDNS] = NULL;
auth->timeout[PROVIDER_RDNS] = 0;
set_provider_data(auth, PROVIDER_RDNS, NULL);
set_provider_timeout_absolute(auth, PROVIDER_RDNS, 0);
provider_done(auth, PROVIDER_RDNS);
}
@ -114,7 +117,7 @@ rdns_destroy(void)
RB_DICTIONARY_FOREACH(auth, &iter, auth_clients)
{
if(auth->data[PROVIDER_RDNS] != NULL)
if(get_provider_data(auth, PROVIDER_RDNS) != NULL)
client_fail(auth, REPORT_FAIL);
}
}
@ -124,8 +127,8 @@ rdns_start(struct auth_client *auth)
{
struct user_query *query = rb_malloc(sizeof(struct user_query));
auth->data[PROVIDER_RDNS] = query;
auth->timeout[PROVIDER_RDNS] = rb_current_time() + rdns_timeout;
set_provider_data(auth, PROVIDER_RDNS, query);
set_provider_timeout_relative(auth, PROVIDER_RDNS, rdns_timeout);
query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth);
@ -137,7 +140,7 @@ rdns_start(struct auth_client *auth)
static void
rdns_cancel(struct auth_client *auth)
{
struct user_query *query = auth->data[PROVIDER_RDNS];
struct user_query *query = get_provider_data(auth, PROVIDER_RDNS);
if(query != NULL)
client_fail(auth, REPORT_FAIL);