]> PatchyGit - patchyircd.git/commitdiff
abort SASL on registration
authorEgor <egor@patchysicp.xyz>
Thu, 25 Jan 2024 02:55:37 +0000 (04:55 +0200)
committerEgor <egor@patchysicp.xyz>
Thu, 25 Jan 2024 02:55:37 +0000 (04:55 +0200)
From the spec:
If the client completes registration (with CAP END, NICK, USER and any
other necessary messages) while the SASL authentication is still in
progress, the server SHOULD abort it and send a 906 numeric, then
register the client without authentication.

src/irc.c

index 2880d7f..ced610d 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -391,7 +391,6 @@ saslcleanup:
                                free(client->saslbuf);
                                client->saslbuf = 0;
                                client->saslbufLen = 0;
-                               newUser(client);
                                return 0;
                        }
                }
@@ -1329,8 +1328,15 @@ unknown:
 }
 
 void newUser(struct client_data *client) {
-       if (client->regstate == REG_CAPLS || client->saslbuf || !client->nick_reg || !client->username)
+       if (client->regstate == REG_CAPLS || !client->nick_reg || !client->username)
                return;
+       if (client->saslbuf) {
+               copy_strf(&databuf, ":%s 906 * :SASL auhtentication aborted\r\n", hostname), sendbuf(client);
+               memset(client->saslbuf, 0, 1024);
+               free(client->saslbuf);
+               client->saslbuf = 0;
+               client->saslbufLen = 0;
+       }
        if (client->username[0] == '~' && client->pass_reg) {
                int res = password_check(client->username + 1, client->pass_reg, getdatafile("users.txt"));
                memset(client->pass_reg, 0, strlen(client->pass_reg));