From 6535177fef2f782593f2f95bf5d2ca709dd46e2d Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Sun, 27 Mar 2016 13:52:52 -0500 Subject: [PATCH] authd/provider: add data to rejection tag. This is used for information such as what blacklist rejected the client. --- authd/provider.c | 13 ++++++++----- authd/provider.h | 2 +- authd/providers/blacklist.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/authd/provider.c b/authd/provider.c index fcd9490a6..941e40595 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -115,7 +115,7 @@ destroy_providers(void) RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) { /* TBD - is this the right thing? */ - reject_client(auth, 0, "Authentication system is down... try reconnecting in a few seconds"); + reject_client(auth, -1, "destroy", "Authentication system is down... try reconnecting in a few seconds"); } RB_DLINK_FOREACH(ptr, auth_providers.head) @@ -161,7 +161,7 @@ provider_done(struct auth_client *auth, provider_t id) { if(!auth->providers_starting) /* Only do this when there are no providers left */ - accept_client(auth, 0); + accept_client(auth, -1); return; } @@ -177,7 +177,7 @@ provider_done(struct auth_client *auth, provider_t id) /* Reject a client - WARNING: do not use auth instance after calling! */ void -reject_client(struct auth_client *auth, provider_t id, const char *reason) +reject_client(struct auth_client *auth, provider_t id, const char *data, const char *reason) { char reject; @@ -197,11 +197,14 @@ reject_client(struct auth_client *auth, provider_t id, const char *reason) break; } + if(data == NULL) + data = "*"; + /* We send back username and hostname in case ircd wants to overrule our decision. * In the future this may not be the case. * --Elizafox */ - rb_helper_write(authd_helper, "R %x %c %s %s :%s", auth->cid, reject, auth->username, auth->hostname, reason); + rb_helper_write(authd_helper, "R %x %c %s %s %s :%s", auth->cid, reject, auth->username, auth->hostname, data, reason); set_provider_off(auth, id); cancel_providers(auth); @@ -285,7 +288,7 @@ start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ /* If no providers are running, accept the client */ if(!auth->providers) - accept_client(auth, 0); + accept_client(auth, -1); } /* Callback for the initiation */ diff --git a/authd/provider.h b/authd/provider.h index a9e99e2c7..3c2773ccd 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -97,7 +97,7 @@ void cancel_providers(struct auth_client *auth); void provider_done(struct auth_client *auth, provider_t id); void accept_client(struct auth_client *auth, provider_t id); -void reject_client(struct auth_client *auth, provider_t id, const char *reason); +void reject_client(struct auth_client *auth, provider_t id, const char *data, const char *reason); void handle_new_connection(int parc, char *parv[]); void handle_cancel_connection(int parc, char *parv[]); diff --git a/authd/providers/blacklist.c b/authd/providers/blacklist.c index c05cb6305..c738b4381 100644 --- a/authd/providers/blacklist.c +++ b/authd/providers/blacklist.c @@ -246,7 +246,7 @@ blacklist_dns_callback(const char *result, bool status, query_type type, void *d { /* Match found, so proceed no further */ blacklists_cancel(auth); - reject_client(auth, PROVIDER_BLACKLIST, bl->reason); + reject_client(auth, PROVIDER_BLACKLIST, bl->host, bl->reason); return; }