]> jfr.im git - solanum.git/blobdiff - extensions/sasl_usercloak.c
sasl_usercloak: make the magic string more specific
[solanum.git] / extensions / sasl_usercloak.c
index cbdac7b99ec9af3d9a4de271b93b3c698bd46d52..bce1c722220e867f8ec3a2258a4e1af13d1d2c33 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 $");
-
-enum
-{
-       D_LINED,
-       K_LINED
-};
-
-static void
-notify_banned_client(struct Client *client_p, struct ConfItem *aconf, int ban)
-{
-       static const char conn_closed[] = "Connection closed";
-       static const char d_lined[] = "D-lined";
-       static const char k_lined[] = "K-lined";
-       const char *reason = NULL;
-       const char *exit_reason = conn_closed;
-
-       if(ConfigFileEntry.kline_with_reason)
-       {
-               reason = get_user_ban_reason(aconf);
-               exit_reason = reason;
-       }
-       else
-       {
-               reason = aconf->status == D_LINED ? d_lined : k_lined;
-       }
-
-       if(ban == D_LINED && !IsPerson(client_p))
-               sendto_one(client_p, "NOTICE DLINE :*** You have been D-lined");
-       else
-               sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
-                          me.name, client_p->name, reason);
-
-       exit_client(client_p, client_p, &me,
-                       EmptyString(ConfigFileEntry.kline_reason) ? exit_reason :
-                        ConfigFileEntry.kline_reason);
-}
 
 unsigned int fnv_hash_string(char *str)
 {
@@ -73,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;
@@ -81,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;
@@ -105,7 +72,7 @@ check_new_user(void *vdata)
                        return;
                }
 
-               char c = ToLower(*src);
+               char c = tolower(*src);
 
                if (IsHostChar(c))
                        *dst++ = c;
@@ -165,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);