From 64afc35817368fca10234f1dc8f8e5dca1b7fa22 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Wed, 30 Mar 2016 01:29:21 -0500 Subject: [PATCH] authd/provider: make reject_client take a format string and varargs --- authd/provider.c | 10 ++++++++-- authd/provider.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/authd/provider.c b/authd/provider.c index f4a0cb5ee..302eebb36 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -184,9 +184,11 @@ 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 *data, const char *reason) +reject_client(struct auth_client *auth, provider_t id, const char *data, const char *fmt, ...) { char reject; + char buf[BUFSIZE]; + va_list args; switch(id) { @@ -207,11 +209,15 @@ reject_client(struct auth_client *auth, provider_t id, const char *data, const c if(data == NULL) data = "*"; + va_begin(fmt, args); + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + /* 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 :%s", auth->cid, reject, auth->username, auth->hostname, data, reason); + rb_helper_write(authd_helper, "R %x %c %s %s %s :%s", auth->cid, reject, auth->username, auth->hostname, data, buf); set_provider_off(auth, id); cancel_providers(auth); diff --git a/authd/provider.h b/authd/provider.h index c5462c931..8ab21ad8b 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -105,7 +105,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 *data, const char *reason); +void reject_client(struct auth_client *auth, provider_t id, const char *data, const char *fmt, ...); void handle_new_connection(int parc, char *parv[]); void handle_cancel_connection(int parc, char *parv[]);