cap: allow clients to do sasl reauth if they requested sasl and sasl-reauth (ref ircv3/ircv3#103).

This commit is contained in:
William Pitcock 2015-02-15 17:10:39 -06:00
parent 0044d40050
commit ef3ab8e3a5
3 changed files with 11 additions and 3 deletions

View file

@ -448,6 +448,7 @@ struct ListClient
#define CLICAP_EXTENDED_JOIN 0x0008 #define CLICAP_EXTENDED_JOIN 0x0008
#define CLICAP_AWAY_NOTIFY 0x0010 #define CLICAP_AWAY_NOTIFY 0x0010
#define CLICAP_TLS 0x0020 #define CLICAP_TLS 0x0020
#define CLICAP_SASL_REAUTH 0x0040
/* /*
* flags macros. * flags macros.

View file

@ -72,6 +72,7 @@ static struct clicap
} clicap_list[] = { } clicap_list[] = {
_CLICAP("multi-prefix", CLICAP_MULTI_PREFIX, 0, 0, 0), _CLICAP("multi-prefix", CLICAP_MULTI_PREFIX, 0, 0, 0),
_CLICAP("sasl", CLICAP_SASL, 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("account-notify", CLICAP_ACCOUNT_NOTIFY, 0, 0, 0),
_CLICAP("extended-join", CLICAP_EXTENDED_JOIN, 0, 0, 0), _CLICAP("extended-join", CLICAP_EXTENDED_JOIN, 0, 0, 0),
_CLICAP("away-notify", CLICAP_AWAY_NOTIFY, 0, 0, 0), _CLICAP("away-notify", CLICAP_AWAY_NOTIFY, 0, 0, 0),

View file

@ -43,7 +43,7 @@
#include "s_newconf.h" #include "s_newconf.h"
#include "s_conf.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 int me_sasl(struct Client *, struct Client *, int, const char **);
static void abort_sasl(struct Client *); static void abort_sasl(struct Client *);
@ -51,7 +51,7 @@ static void abort_sasl_exit(hook_data_client_exit *);
struct Message authenticate_msgtab = { struct Message authenticate_msgtab = {
"AUTHENTICATE", 0, 0, 0, MFLG_SLOW, "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 = { struct Message sasl_msgtab = {
"SASL", 0, 0, 0, MFLG_SLOW, "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 $"); DECLARE_MODULE_AV1(sasl, NULL, NULL, sasl_clist, NULL, sasl_hfnlist, "$Revision: 1409 $");
static int 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[]) int parc, const char *parv[])
{ {
struct Client *agent_p = NULL; 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)) if(!IsCapable(source_p, CLICAP_SASL))
return 0; 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) if (strlen(client_p->id) == 3)
{ {
exit_client(client_p, client_p, client_p, "Mixing client and server protocol"); exit_client(client_p, client_p, client_p, "Mixing client and server protocol");