X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/a03c04b3ed639cb7cc0d4bf6d8f61a9858c84239..8c684fca9c7dbb4a2601628c744be9236ee68641:/chanserv/database/chanservdb_hash.c diff --git a/chanserv/database/chanservdb_hash.c b/chanserv/database/chanservdb_hash.c index 9f934c7c..34ab783c 100644 --- a/chanserv/database/chanservdb_hash.c +++ b/chanserv/database/chanservdb_hash.c @@ -6,6 +6,7 @@ */ #include +#include #include "../chanserv.h" #include "../../lib/irc_string.h" @@ -34,7 +35,7 @@ void addregusertohash(reguser *rup) { rup->nextbyname=regusernicktable[hash]; regusernicktable[hash]=rup; - anp=findorcreateauthname(rup->ID); + anp=findorcreateauthname(rup->ID, rup->username); anp->exts[chanservaext]=rup; } @@ -72,7 +73,7 @@ reguser *findreguserbyemail(const char *email) { for (i=0;inextbyname) { - if (!strcasecmp(email,rup->email->content)) { + if (rup->email && !strcasecmp(email,rup->email->content)) { return rup; } } @@ -214,7 +215,7 @@ maildomain *findnearestmaildomain(char *domain) { if(!m && (p=strchr(domain, '.'))) return findnearestmaildomain(++p); - return NULL; + return m; } maildomain *findmaildomainbyemail(char *email) { @@ -315,10 +316,13 @@ void addregusertomaildomain(reguser *rup, maildomain *mdp) { } void delreguserfrommaildomain(reguser *rup, maildomain *mdp) { - maildomain *smdp; + maildomain *smdp, *nmdp; reguser *ruh, *pruh=NULL; int found=0; + if(!mdp) + return; + for (ruh=mdp->users; ruh; ruh=ruh->nextbydomain) { if (ruh==rup) { /* Found the user */ @@ -338,16 +342,21 @@ void delreguserfrommaildomain(reguser *rup, maildomain *mdp) { return; } - for(smdp=mdp;smdp;smdp=smdp->parent) { - smdp->count--; + /* Free it from all the parent domains, cleaning up as we go.. */ + for(smdp=mdp;smdp;smdp=nmdp) { + nmdp=smdp->parent; + + /* Keep it if there are users left or we're remembering something about it. */ + if (--smdp->count || (smdp->flags != MDFLAG_DEFAULT) || (smdp->actlimit != MD_DEFAULTACTLIMIT)) + continue; + + removemaildomainfromhash(smdp); + freesstring(smdp->name); + freemaildomain(smdp); } + rup->domain=NULL; freesstring(rup->localpart); rup->localpart=NULL; - - if (!mdp->count && !MDHasLimit(mdp)) { - removemaildomainfromhash(mdp); - freemaildomain(mdp); - } }