Permalink
Browse files

Allow SASL post-registration. Unfortunately the anope unreal4 protocol

module also requires an update to support this.
  • Loading branch information...
syzop committed Feb 9, 2019
1 parent dde8f91 commit 78cd122a050d32b1c352c7142a41e9264344f9aa
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/modules/m_sasl.c
@@ -106,6 +106,9 @@ static const char *encode_puid(aClient *client)
{
static char buf[HOSTLEN + 20];

if (MyClient(client))
return client->id;

/* create a cookie if necessary (and in case getrandom16 returns 0, then run again) */
while (!client->local->sasl_cookie)
client->local->sasl_cookie = getrandom16();
@@ -131,8 +134,12 @@ CMD_FUNC(m_svslogin)
{
aClient *target_p;

target_p = find_client(parv[2], NULL);
if (target_p && !MyConnect(target_p))
return 0;

/* is the PUID valid? */
if ((target_p = decode_puid(parv[2])) == NULL)
if (!target_p && ((target_p = decode_puid(parv[2])) == NULL))
return 0;

if (target_p->user == NULL)
@@ -175,8 +182,12 @@ CMD_FUNC(m_sasl)
{
aClient *target_p;

target_p = find_client(parv[2], NULL);
if (target_p && !MyConnect(target_p))
return 0;

/* is the PUID valid? */
if ((target_p = decode_puid(parv[2])) == NULL)
if (!target_p && ((target_p = decode_puid(parv[2])) == NULL))
return 0;

if (target_p->user == NULL)
@@ -235,12 +246,6 @@ CMD_FUNC(m_authenticate)
if (!SASL_SERVER || !MyConnect(sptr) || BadPtr(parv[1]) || !CHECKPROTO(sptr, PROTO_SASL))
return 0;

if (sptr->local->sasl_complete)
{
sendto_one(sptr, err_str(ERR_SASLALREADY), me.name, BadPtr(sptr->name) ? "*" : sptr->name);
return 0;
}

if ((parv[1][0] == ':') || strchr(parv[1], ' '))
{
sendto_one(sptr, err_str(ERR_CANNOTDOCOMMAND), me.name, "*", "AUTHENTICATE", "Invalid parameter");
@@ -401,7 +406,7 @@ MOD_INIT(m_sasl)

CommandAdd(modinfo->handle, MSG_SASL, m_sasl, MAXPARA, M_USER|M_SERVER);
CommandAdd(modinfo->handle, MSG_SVSLOGIN, m_svslogin, MAXPARA, M_USER|M_SERVER);
CommandAdd(modinfo->handle, MSG_AUTHENTICATE, m_authenticate, MAXPARA, M_UNREGISTERED);
CommandAdd(modinfo->handle, MSG_AUTHENTICATE, m_authenticate, MAXPARA, M_UNREGISTERED|M_USER);

HookAdd(modinfo->handle, HOOKTYPE_LOCAL_CONNECT, 0, sasl_connect);
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_QUIT, 0, sasl_quit);

0 comments on commit 78cd122

Please sign in to comment.