]> jfr.im git - solanum.git/blobdiff - extensions/sasl_usercloak.c
callerid: actually the guard should be for source_p
[solanum.git] / extensions / sasl_usercloak.c
index cc4e81aabd16a7dc4fb2f17665692ded49f39ef4..c70b0812900679ee09aeb9edbada43cd3d31f61f 100644 (file)
 
 #include <stdint.h>
 
+static const char sasl_usercloak_desc[] =
+       "Insert the SASL account name into certain iline spoofed hosts";
+
 static void check_new_user(void *data);
 mapi_hfn_list_av1 sasl_usercloak_hfnlist[] = {
-       { "new_local_user", (hookfn) check_new_user },
+       { "new_local_user", check_new_user },
        { NULL, NULL }
 };
 
-DECLARE_MODULE_AV1(sasl_usercloak, NULL, NULL, NULL, NULL,
-                       sasl_usercloak_hfnlist, "$Revision: 3526 $");
-
 
 unsigned int fnv_hash_string(char *str)
 {
@@ -38,7 +38,7 @@ unsigned int fnv_hash_string(char *str)
 static void
 check_new_user(void *vdata)
 {
-       struct Client *source_p = (void *)vdata;
+       struct Client *source_p = vdata;
 
        if (!IsIPSpoof(source_p))
                return;
@@ -46,10 +46,12 @@ check_new_user(void *vdata)
        if (EmptyString(source_p->user->suser))
                return;
 
-       char *accountpart = strstr(source_p->orighost, "account");
-       if (!accountpart)
+       char *accountpart = strstr(source_p->orighost, "/account");
+       if (!accountpart || accountpart[8] != '\0')
                return;
 
+       accountpart += 1;
+
        char buf[HOSTLEN];
        memset(buf, 0, sizeof(buf));
        char *dst = buf;
@@ -70,7 +72,7 @@ check_new_user(void *vdata)
                        return;
                }
 
-               char c = ToLower(*src);
+               char c = tolower(*src);
 
                if (IsHostChar(c))
                        *dst++ = c;
@@ -95,7 +97,7 @@ check_new_user(void *vdata)
 
                unsigned int hashval = fnv_hash_string(source_p->user->suser);
                hashval %= 100000000; // eight digits only please.
-               snprintf(dst, 9, "%08ud", hashval);
+               snprintf(dst, 9, "%08u", hashval);
        }
 
        /* just in case */
@@ -130,3 +132,5 @@ check_new_user(void *vdata)
                notify_banned_client(source_p, aconf, K_LINED);
        }
 }
+
+DECLARE_MODULE_AV2(sasl_usercloak, NULL, NULL, NULL, NULL, sasl_usercloak_hfnlist, NULL, NULL, sasl_usercloak_desc);