15 static void check_new_user(void *data
);
16 mapi_hfn_list_av1 sasl_usercloak_hfnlist
[] = {
17 { "new_local_user", (hookfn
) check_new_user
},
21 DECLARE_MODULE_AV1(sasl_usercloak
, NULL
, NULL
, NULL
, NULL
,
22 sasl_usercloak_hfnlist
, "$Revision: 3526 $");
24 unsigned int fnv_hash_string(char *str
)
26 unsigned int hash
= 0x811c9dc5; // Magic value for 32-bit fnv1 hash initialisation.
27 unsigned char *p
= (unsigned char *)str
;
30 hash
+= (hash
<<1) + (hash
<<4) + (hash
<<7) + (hash
<<8) + (hash
<<24);
37 check_new_user(void *vdata
)
39 struct Client
*source_p
= (void *)vdata
;
41 if (!IsIPSpoof(source_p
))
44 if (EmptyString(source_p
->user
->suser
))
47 char *accountpart
= strstr(source_p
->host
, "account");
54 strncpy(buf
, source_p
->host
, accountpart
- source_p
->host
);
55 dst
+= accountpart
- source_p
->host
;
59 for (char *src
= source_p
->user
->suser
; *src
; src
++ )
61 if (dst
> buf
+ sizeof(buf
))
63 /* Doesn't fit. Warn opers and bail. */
64 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
65 "Couldn't fit account name part %s in hostname for %s!%s@%s",
66 source_p
->user
->suser
, source_p
->name
, source_p
->username
, source_p
->host
);
70 char c
= ToLower(*src
);
80 if (dst
> buf
+ sizeof(buf
) - 12) /* '/x-' plus eight digit hash plus null terminator */
82 /* Doesn't fit. Warn opers and bail. */
83 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
84 "Couldn't fit account name part %s in hostname for %s!%s@%s",
85 source_p
->user
->suser
, source_p
->name
, source_p
->user
, source_p
->host
);
93 unsigned int hashval
= fnv_hash_string(source_p
->user
->suser
);
94 hashval
%= 100000000; // eight digits only please.
95 snprintf(dst
, 9, "%08ud", hashval
);
99 buf
[HOSTLEN
-1] = '\0';
101 change_nick_user_host(source_p
, source_p
->name
, source_p
->username
, buf
, 0, "Changing host");