mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-24 22:40:18 +00:00
Moved SASL PLAIN authentication to own function
This commit is contained in:
committed by
Patrick Griffis
parent
44d14a436b
commit
50ca0d5b09
@@ -1901,34 +1901,10 @@ inbound_cap_list (server *serv, char *nick, char *extensions,
|
||||
NULL, NULL, 0, tags_data->timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
inbound_sasl_authenticate (server *serv, char *data)
|
||||
static void
|
||||
plain_authenticate(server *serv, char *user, char *password)
|
||||
{
|
||||
ircnet *net = (ircnet*)serv->network;
|
||||
char *user, *pass = NULL;
|
||||
const char *mech = sasl_mechanisms[serv->sasl_mech];
|
||||
|
||||
/* Got a list of supported mechanisms from outdated inspircd
|
||||
* just ignore it as it goes against spec */
|
||||
if (strchr (data, ',') != NULL)
|
||||
return;
|
||||
|
||||
if (net->user && !(net->flags & FLAG_USE_GLOBAL))
|
||||
user = net->user;
|
||||
else
|
||||
user = prefs.hex_irc_user_name;
|
||||
|
||||
switch (serv->sasl_mech)
|
||||
{
|
||||
case MECH_PLAIN:
|
||||
pass = encode_sasl_pass_plain (user, serv->password);
|
||||
break;
|
||||
#ifdef USE_OPENSSL
|
||||
case MECH_EXTERNAL:
|
||||
pass = g_strdup ("+");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
char *pass = encode_sasl_pass_plain (user, password);
|
||||
|
||||
if (pass == NULL)
|
||||
{
|
||||
@@ -1955,8 +1931,36 @@ inbound_sasl_authenticate (server *serv, char *data)
|
||||
}
|
||||
if (pass_len % 400 == 0)
|
||||
tcp_sendf (serv, "AUTHENTICATE +\r\n");
|
||||
g_free (pass);
|
||||
}
|
||||
|
||||
void
|
||||
inbound_sasl_authenticate (server *serv, char *data)
|
||||
{
|
||||
ircnet *net = (ircnet*)serv->network;
|
||||
char *user, *pass = NULL;
|
||||
const char *mech = sasl_mechanisms[serv->sasl_mech];
|
||||
|
||||
/* Got a list of supported mechanisms from outdated inspircd
|
||||
* just ignore it as it goes against spec */
|
||||
if (strchr (data, ',') != NULL)
|
||||
return;
|
||||
|
||||
if (net->user && !(net->flags & FLAG_USE_GLOBAL))
|
||||
user = net->user;
|
||||
else
|
||||
user = prefs.hex_irc_user_name;
|
||||
|
||||
switch (serv->sasl_mech)
|
||||
{
|
||||
case MECH_PLAIN:
|
||||
plain_authenticate(serv, user, serv->password);
|
||||
break;
|
||||
#ifdef USE_OPENSSL
|
||||
case MECH_EXTERNAL:
|
||||
tcp_sendf (serv, "AUTHENTICATE +\r\n");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_SASLAUTH, serv->server_session, user, (char*)mech,
|
||||
NULL, NULL, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user