]> jfr.im git - irc/atheme/atheme.git/commitdiff
saslserv: call bad_password on SASL authentication failure
authorJanik Kleinhoff <redacted>
Tue, 3 Feb 2015 20:01:28 +0000 (20:01 +0000)
committerJanik Kleinhoff <redacted>
Tue, 3 Feb 2015 21:13:32 +0000 (21:13 +0000)
modules/saslserv/main.c

index f173de08ab9cf1517bb011598fd9433fc36a400c..97e5b9a2086925165b23f51d59d28ab8f95ebcef 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "atheme.h"
+#include "uplink.h"
 
 DECLARE_MODULE_V1
 (
@@ -38,6 +39,10 @@ static void mechlist_do_rebuild();
 
 sasl_mech_register_func_t sasl_mech_register_funcs = { &sasl_mech_register, &sasl_mech_unregister };
 
+struct sourceinfo_vtable sasl_vtable = {
+       .description = "sasl"
+};
+
 /* main services client routine */
 static void saslserv(sourceinfo_t *si, int parc, char *parv[])
 {
@@ -441,6 +446,27 @@ static void sasl_packet(sasl_session_t *p, char *buf, int len)
                }
        }
 
+       /* If we reach this, they failed SASL auth, so if they were trying
+        * to identify as a specific user, bad_password them.
+        */
+       if (p->username)
+       {
+               myuser_t *mu = myuser_find_by_nick(p->username);
+               if (mu)
+               {
+                       sourceinfo_t *si = sourceinfo_create();
+                       si->service = saslsvs;
+                       si->sourcedesc = p->uid;
+                       si->connection = curr_uplink->conn;
+                       si->v = &sasl_vtable;
+                       si->force_language = language_find("en");
+
+                       bad_password(si, mu);
+
+                       object_unref(si);
+               }
+       }
+
        free(out);
        sasl_sts(p->uid, 'D', "F");
        destroy_session(p);