From ef3ab8e3a5c98c9750a057bc74e9c783237c05e1 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 15 Feb 2015 17:10:39 -0600 Subject: [PATCH] cap: allow clients to do sasl reauth if they requested sasl and sasl-reauth (ref ircv3/ircv3#103). --- include/client.h | 1 + modules/m_cap.c | 1 + modules/m_sasl.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/client.h b/include/client.h index c54ea2b98..171ddd475 100644 --- a/include/client.h +++ b/include/client.h @@ -448,6 +448,7 @@ struct ListClient #define CLICAP_EXTENDED_JOIN 0x0008 #define CLICAP_AWAY_NOTIFY 0x0010 #define CLICAP_TLS 0x0020 +#define CLICAP_SASL_REAUTH 0x0040 /* * flags macros. diff --git a/modules/m_cap.c b/modules/m_cap.c index 967c1b7e9..a17016df5 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -72,6 +72,7 @@ static struct clicap } clicap_list[] = { _CLICAP("multi-prefix", CLICAP_MULTI_PREFIX, 0, 0, 0), _CLICAP("sasl", CLICAP_SASL, 0, 0, 0), + _CLICAP("sasl-reauth", CLICAP_SASL_REAUTH, 0, CLICAP_SASL, 0), _CLICAP("account-notify", CLICAP_ACCOUNT_NOTIFY, 0, 0, 0), _CLICAP("extended-join", CLICAP_EXTENDED_JOIN, 0, 0, 0), _CLICAP("away-notify", CLICAP_AWAY_NOTIFY, 0, 0, 0), diff --git a/modules/m_sasl.c b/modules/m_sasl.c index 9b1399515..852a88e03 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -43,7 +43,7 @@ #include "s_newconf.h" #include "s_conf.h" -static int mr_authenticate(struct Client *, struct Client *, int, const char **); +static int m_authenticate(struct Client *, struct Client *, int, const char **); static int me_sasl(struct Client *, struct Client *, int, const char **); static void abort_sasl(struct Client *); @@ -51,7 +51,7 @@ static void abort_sasl_exit(hook_data_client_exit *); struct Message authenticate_msgtab = { "AUTHENTICATE", 0, 0, 0, MFLG_SLOW, - {{mr_authenticate, 2}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg} + {{m_authenticate, 2}, {m_authenticate, 2}, mg_ignore, mg_ignore, mg_ignore, {m_authenticate, 2}} }; struct Message sasl_msgtab = { "SASL", 0, 0, 0, MFLG_SLOW, @@ -70,7 +70,7 @@ mapi_hfn_list_av1 sasl_hfnlist[] = { DECLARE_MODULE_AV1(sasl, NULL, NULL, sasl_clist, NULL, sasl_hfnlist, "$Revision: 1409 $"); static int -mr_authenticate(struct Client *client_p, struct Client *source_p, +m_authenticate(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *agent_p = NULL; @@ -80,6 +80,12 @@ mr_authenticate(struct Client *client_p, struct Client *source_p, if(!IsCapable(source_p, CLICAP_SASL)) return 0; + if(IsRegisteredUser(source_p) && !IsCapable(source_p, CLICAP_SASL_REAUTH)) + { + sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), me.name, source_p->name); + return 0; + } + if (strlen(client_p->id) == 3) { exit_client(client_p, client_p, client_p, "Mixing client and server protocol");