diff options
| author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
|---|---|---|
| committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
| commit | 6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 (patch) | |
| tree | 91b0841faf23087ebe0c74dd4269d181a383f1e7 /src/users.c | |
| parent | 069409cd99cf78ab8bf87a1fe69a833576414fd3 (diff) | |
Insane commit of doom: s/ \t/g
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1681 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/users.c')
| -rw-r--r-- | src/users.c | 1246 |
1 files changed, 623 insertions, 623 deletions
diff --git a/src/users.c b/src/users.c index f03b39837..fba9a6611 100644 --- a/src/users.c +++ b/src/users.c @@ -70,8 +70,8 @@ User::User(const std::string &snick) alog("user: New maximum user count: %d", maxusercnt); } - this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */ - this->nickTrack = NULL; /* ensure no default tracking nick */ + this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */ + this->nickTrack = NULL; /* ensure no default tracking nick */ } void User::SetNewNick(const std::string &newnick) @@ -114,8 +114,8 @@ void User::SetNewNick(const std::string &newnick) this->na->u = this; } - if (debug) - alog("debug: %s changed nick to %s", this->nick, newnick.c_str()); + if (debug) + alog("debug: %s changed nick to %s", this->nick, newnick.c_str()); } void User::SetDisplayedHost(const std::string &shost) @@ -123,14 +123,14 @@ void User::SetDisplayedHost(const std::string &shost) if (shost.empty()) throw "empty host? in MY services? it seems it's more likely than I thought."; - if (this->vhost) - free(this->vhost); - this->vhost = sstrdup(shost.c_str()); + if (this->vhost) + free(this->vhost); + this->vhost = sstrdup(shost.c_str()); - if (debug) - alog("debug: %s changed vhost to %s", this->nick, shost.c_str()); + if (debug) + alog("debug: %s changed vhost to %s", this->nick, shost.c_str()); - update_host(this); + update_host(this); } void User::SetIdent(const std::string &ident) @@ -315,18 +315,18 @@ void User::SendMessage(const char *source, const std::string &msg) */ void update_host(User * user) { - if (user->na && (nick_identified(user) - || (!(user->na->nc->flags & NI_SECURE) - && nick_recognized(user)))) { - if (user->na->last_usermask) - free(user->na->last_usermask); - - user->na->last_usermask = - (char *)smalloc(strlen(common_get_vident(user)) + - strlen(common_get_vhost(user)) + 2); - sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), - common_get_vhost(user)); - } + if (user->na && (nick_identified(user) + || (!(user->na->nc->flags & NI_SECURE) + && nick_recognized(user)))) { + if (user->na->last_usermask) + free(user->na->last_usermask); + + user->na->last_usermask = + (char *)smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), + common_get_vhost(user)); + } } /*************************************************************************/ @@ -337,36 +337,36 @@ void update_host(User * user) void get_user_stats(long *nusers, long *memuse) { - long count = 0, mem = 0; - int i; - User *user; - struct u_chanlist *uc; - struct u_chaninfolist *uci; - - for (i = 0; i < 1024; i++) { - for (user = userlist[i]; user; user = user->next) { - count++; - mem += sizeof(*user); - if (user->username) - mem += strlen(user->username) + 1; - if (user->host) - mem += strlen(user->host) + 1; - if (ircd->vhost) { - if (user->vhost) - mem += strlen(user->vhost) + 1; - } - if (user->realname) - mem += strlen(user->realname) + 1; - if (user->server->name) - mem += strlen(user->server->name) + 1; - for (uc = user->chans; uc; uc = uc->next) - mem += sizeof(*uc); - for (uci = user->founder_chans; uci; uci = uci->next) - mem += sizeof(*uci); - } - } - *nusers = count; - *memuse = mem; + long count = 0, mem = 0; + int i; + User *user; + struct u_chanlist *uc; + struct u_chaninfolist *uci; + + for (i = 0; i < 1024; i++) { + for (user = userlist[i]; user; user = user->next) { + count++; + mem += sizeof(*user); + if (user->username) + mem += strlen(user->username) + 1; + if (user->host) + mem += strlen(user->host) + 1; + if (ircd->vhost) { + if (user->vhost) + mem += strlen(user->vhost) + 1; + } + if (user->realname) + mem += strlen(user->realname) + 1; + if (user->server->name) + mem += strlen(user->server->name) + 1; + for (uc = user->chans; uc; uc = uc->next) + mem += sizeof(*uc); + for (uci = user->founder_chans; uci; uci = uci->next) + mem += sizeof(*uci); + } + } + *nusers = count; + *memuse = mem; } /*************************************************************************/ @@ -375,23 +375,23 @@ void get_user_stats(long *nusers, long *memuse) User *finduser(const char *nick) { - User *user; - - if (!nick || !*nick) { - if (debug) { - alog("debug: finduser() called with NULL values"); - } - return NULL; - } - - if (debug >= 3) - alog("debug: finduser(%p)", nick); - user = userlist[HASH(nick)]; - while (user && stricmp(user->nick, nick) != 0) - user = user->next; - if (debug >= 3) - alog("debug: finduser(%s) -> 0x%p", nick, (void *) user); - return user; + User *user; + + if (!nick || !*nick) { + if (debug) { + alog("debug: finduser() called with NULL values"); + } + return NULL; + } + + if (debug >= 3) + alog("debug: finduser(%p)", nick); + user = userlist[HASH(nick)]; + while (user && stricmp(user->nick, nick) != 0) + user = user->next; + if (debug >= 3) + alog("debug: finduser(%s) -> 0x%p", nick, (void *) user); + return user; } @@ -404,51 +404,51 @@ static int next_index; User *firstuser(void) { - next_index = 0; - current = NULL; - while (next_index < 1024 && current == NULL) - current = userlist[next_index++]; - if (debug) - alog("debug: firstuser() returning %s", - current ? current->nick : "NULL (end of list)"); - return current; + next_index = 0; + current = NULL; + while (next_index < 1024 && current == NULL) + current = userlist[next_index++]; + if (debug) + alog("debug: firstuser() returning %s", + current ? current->nick : "NULL (end of list)"); + return current; } User *nextuser(void) { - if (current) - current = current->next; - if (!current && next_index < 1024) { - while (next_index < 1024 && current == NULL) - current = userlist[next_index++]; - } - if (debug) - alog("debug: nextuser() returning %s", - current ? current->nick : "NULL (end of list)"); - return current; + if (current) + current = current->next; + if (!current && next_index < 1024) { + while (next_index < 1024 && current == NULL) + current = userlist[next_index++]; + } + if (debug) + alog("debug: nextuser() returning %s", + current ? current->nick : "NULL (end of list)"); + return current; } User *find_byuid(const char *uid) { - User *u, *next; - - if (!uid) { - if (debug) - alog("debug: find_byuid() called with NULL-value"); - return NULL; - } - - u = first_uid(); - while (u) { - next = next_uid(); - if (u->uid) { - if (!stricmp(uid, u->uid)) { - return u; - } - } - u = next; - } - return NULL; + User *u, *next; + + if (!uid) { + if (debug) + alog("debug: find_byuid() called with NULL-value"); + return NULL; + } + + u = first_uid(); + while (u) { + next = next_uid(); + if (u->uid) { + if (!stricmp(uid, u->uid)) { + return u; + } + } + u = next; + } + return NULL; } static User *current_uid; @@ -456,33 +456,33 @@ static int next_index_uid; User *first_uid(void) { - next_index_uid = 0; - current_uid = NULL; - while (next_index_uid < 1024 && current_uid == NULL) { - current_uid = userlist[next_index_uid++]; - } - if (debug >= 2) { - alog("debug: first_uid() returning %s %s", - current_uid ? current_uid->nick : "NULL (end of list)", - current_uid ? current_uid->uid : ""); - } - return current_uid; + next_index_uid = 0; + current_uid = NULL; + while (next_index_uid < 1024 && current_uid == NULL) { + current_uid = userlist[next_index_uid++]; + } + if (debug >= 2) { + alog("debug: first_uid() returning %s %s", + current_uid ? current_uid->nick : "NULL (end of list)", + current_uid ? current_uid->uid : ""); + } + return current_uid; } User *next_uid(void) { - if (current_uid) - current_uid = current_uid->next; - if (!current_uid && next_index_uid < 1024) { - while (next_index_uid < 1024 && current_uid == NULL) - current_uid = userlist[next_index_uid++]; - } - if (debug >= 2) { - alog("debug: next_uid() returning %s %s", - current_uid ? current_uid->nick : "NULL (end of list)", - current_uid ? current_uid->uid : ""); - } - return current_uid; + if (current_uid) + current_uid = current_uid->next; + if (!current_uid && next_index_uid < 1024) { + while (next_index_uid < 1024 && current_uid == NULL) + current_uid = userlist[next_index_uid++]; + } + if (debug >= 2) { + alog("debug: next_uid() returning %s %s", + current_uid ? current_uid->nick : "NULL (end of list)", + current_uid ? current_uid->uid : ""); + } + return current_uid; } /*************************************************************************/ @@ -491,297 +491,297 @@ User *next_uid(void) /* Handle a server NICK command. */ User *do_nick(const char *source, const char *nick, const char *username, const char *host, - const char *server, const char *realname, time_t ts, uint32 svid, - uint32 ip, const char *vhost, const char *uid) + const char *server, const char *realname, time_t ts, uint32 svid, + uint32 ip, const char *vhost, const char *uid) { - User *user = NULL; - - char *tmp = NULL; - NickAlias *old_na; /* Old nick rec */ - int nc_changed = 1; /* Did nick core change? */ - int status = 0; /* Status to apply */ - char mask[USERMAX + HOSTMAX + 2]; - char *logrealname; - - if (!*source) { - char ipbuf[16]; - struct in_addr addr; - - if (ircd->nickvhost) { - if (vhost) { - if (!strcmp(vhost, "*")) { - vhost = NULL; - if (debug) - alog("debug: new user�with no vhost in NICK command: %s", nick); - } - } - } - - /* This is a new user; create a User structure for it. */ - if (debug) - alog("debug: new user: %s", nick); - - if (ircd->nickip) { - addr.s_addr = htonl(ip); - ntoa(addr, ipbuf, sizeof(ipbuf)); - } - - - if (LogUsers) { - /** + User *user = NULL; + + char *tmp = NULL; + NickAlias *old_na; /* Old nick rec */ + int nc_changed = 1; /* Did nick core change? */ + int status = 0; /* Status to apply */ + char mask[USERMAX + HOSTMAX + 2]; + char *logrealname; + + if (!*source) { + char ipbuf[16]; + struct in_addr addr; + + if (ircd->nickvhost) { + if (vhost) { + if (!strcmp(vhost, "*")) { + vhost = NULL; + if (debug) + alog("debug: new user�with no vhost in NICK command: %s", nick); + } + } + } + + /* This is a new user; create a User structure for it. */ + if (debug) + alog("debug: new user: %s", nick); + + if (ircd->nickip) { + addr.s_addr = htonl(ip); + ntoa(addr, ipbuf, sizeof(ipbuf)); + } + + + if (LogUsers) { + /** * Ugly swap routine for Flop's bug :) **/ - if (realname) { - tmp = strchr(realname, '%'); - while (tmp) { - *tmp = '-'; - tmp = strchr(realname, '%'); - } - } - logrealname = normalizeBuffer(realname); - - /** + if (realname) { + tmp = strchr(realname, '%'); + while (tmp) { + *tmp = '-'; + tmp = strchr(realname, '%'); + } + } + logrealname = normalizeBuffer(realname); + + /** * End of ugly swap **/ - if (ircd->nickvhost) { - if (ircd->nickip) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, ipbuf, server); - } else { - alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, server); - } - } else { - if (ircd->nickip) { - alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, logrealname, ipbuf, server); - } else { - alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, logrealname, server); - } - } - Anope_Free(logrealname); - } - - /* We used to ignore the ~ which a lot of ircd's use to indicate no - * identd response. That caused channel bans to break, so now we - * just take what the server gives us. People are still encouraged - * to read the RFCs and stop doing anything to usernames depending - * on the result of an identd lookup. - */ - - /* First check for AKILLs. */ - /* DONT just return null if its an akill match anymore - yes its more efficent to, however, now that ircd's are - * starting to use things like E/F lines, we cant be 100% sure the client will be removed from the network :/ - * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice - * comes in from the ircd. - **/ - if (check_akill(nick, username, host, vhost, ipbuf)) { -/* return NULL; */ - } + if (ircd->nickvhost) { + if (ircd->nickip) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, ipbuf, server); + } else { + alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, server); + } + } else { + if (ircd->nickip) { + alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, logrealname, ipbuf, server); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, logrealname, server); + } + } + Anope_Free(logrealname); + } + + /* We used to ignore the ~ which a lot of ircd's use to indicate no + * identd response. That caused channel bans to break, so now we + * just take what the server gives us. People are still encouraged + * to read the RFCs and stop doing anything to usernames depending + * on the result of an identd lookup. + */ + + /* First check for AKILLs. */ + /* DONT just return null if its an akill match anymore - yes its more efficent to, however, now that ircd's are + * starting to use things like E/F lines, we cant be 100% sure the client will be removed from the network :/ + * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice + * comes in from the ircd. + **/ + if (check_akill(nick, username, host, vhost, ipbuf)) { +/* return NULL; */ + } /** * DefCon AKILL system, if we want to akill all connecting user's here's where to do it * then force check_akill again on them... **/ - /* don't akill on netmerges -Certus */ - /* don't akill clients introduced by ulines. -Viper */ - if (is_sync(findserver(servlist, server)) - && checkDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(server)) { - strncpy(mask, "*@", 3); - strncat(mask, host, HOSTMAX); - alog("DEFCON: adding akill for %s", mask); - add_akill(NULL, mask, s_OperServ, - time(NULL) + DefConAKILL, - DefConAkillReason ? DefConAkillReason : - "DEFCON AKILL"); - if (check_akill(nick, username, host, vhost, ipbuf)) { -/* return NULL; */ - } - } - - /* SGLINE */ - if (ircd->sgline) { - if (check_sgline(nick, realname)) - return NULL; - } - - /* SQLINE */ - if (ircd->sqline) { - if (check_sqline(nick, 0)) - return NULL; - } - - /* SZLINE */ - if (ircd->szline && ircd->nickip) { - if (check_szline(nick, ipbuf)) - return NULL; - } - /* Now check for session limits */ - if (LimitSessions && !is_ulined(server) - && !add_session(nick, host, ipbuf)) - return NULL; - - /* Allocate User structure and fill it in. */ + /* don't akill on netmerges -Certus */ + /* don't akill clients introduced by ulines. -Viper */ + if (is_sync(findserver(servlist, server)) + && checkDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(server)) { + strncpy(mask, "*@", 3); + strncat(mask, host, HOSTMAX); + alog("DEFCON: adding akill for %s", mask); + add_akill(NULL, mask, s_OperServ, + time(NULL) + DefConAKILL, + DefConAkillReason ? DefConAkillReason : + "DEFCON AKILL"); + if (check_akill(nick, username, host, vhost, ipbuf)) { +/* return NULL; */ + } + } + + /* SGLINE */ + if (ircd->sgline) { + if (check_sgline(nick, realname)) + return NULL; + } + + /* SQLINE */ + if (ircd->sqline) { + if (check_sqline(nick, 0)) + return NULL; + } + + /* SZLINE */ + if (ircd->szline && ircd->nickip) { + if (check_szline(nick, ipbuf)) + return NULL; + } + /* Now check for session limits */ + if (LimitSessions && !is_ulined(server) + && !add_session(nick, host, ipbuf)) + return NULL; + + /* Allocate User structure and fill it in. */ user = new User(nick); - user->username = sstrdup(username); - user->host = sstrdup(host); - user->server = findserver(servlist, server); - user->realname = sstrdup(realname); - user->timestamp = ts; - user->my_signon = time(NULL); - user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); - if (uid) { - user->uid = sstrdup(uid); /* p10/ts6 stuff */ - } else { - user->uid = NULL; - } - user->vident = sstrdup(username); - /* We now store the user's ip in the user_ struct, - * because we will use it in serveral places -- DrStein */ - if (ircd->nickip) { - user->hostip = sstrdup(ipbuf); - } else { - user->hostip = NULL; - } - - if (svid == 0) { - display_news(user, NEWS_LOGON); - display_news(user, NEWS_RANDOM); - } - - if (svid == ts && user->na) { - /* Timestamp and svid match, and nick is registered; automagically identify the nick */ - user->svid = svid; - user->na->status |= NS_IDENTIFIED; - check_memos(user); - nc_changed = 0; - - /* Start nick tracking if available */ - if (NSNickTracking) - nsStartNickTracking(user); - - } else if (svid != 1) { - /* Resets the svid because it doesn't match */ - user->svid = 1; - - ircdproto->SendSVID(user->nick, user->timestamp); - - } else { - user->svid = 1; - } - send_event(EVENT_NEWNICK, 1, nick); - - } else { - /* An old user changing nicks. */ - if (UseTS6) - user = find_byuid(source); - - if (!user) - user = finduser(source); - - if (!user) { - alog("user: NICK from nonexistent nick %s", source); - return NULL; - } - user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ - if (debug) - alog("debug: %s changes nick to %s", source, nick); - - if (LogUsers) { - logrealname = normalizeBuffer(user->realname); - if (ircd->vhost) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), logrealname, nick, user->server->name); - } else { - alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", - user->nick, user->username, user->host, logrealname, - nick, user->server->name); - } - if (logrealname) { - free(logrealname); - } - } - - user->timestamp = ts; - - if (stricmp(nick, user->nick) == 0) { - /* No need to redo things */ + user->username = sstrdup(username); + user->host = sstrdup(host); + user->server = findserver(servlist, server); + user->realname = sstrdup(realname); + user->timestamp = ts; + user->my_signon = time(NULL); + user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); + if (uid) { + user->uid = sstrdup(uid); /* p10/ts6 stuff */ + } else { + user->uid = NULL; + } + user->vident = sstrdup(username); + /* We now store the user's ip in the user_ struct, + * because we will use it in serveral places -- DrStein */ + if (ircd->nickip) { + user->hostip = sstrdup(ipbuf); + } else { + user->hostip = NULL; + } + + if (svid == 0) { + display_news(user, NEWS_LOGON); + display_news(user, NEWS_RANDOM); + } + + if (svid == ts && user->na) { + /* Timestamp and svid match, and nick is registered; automagically identify the nick */ + user->svid = svid; + user->na->status |= NS_IDENTIFIED; + check_memos(user); + nc_changed = 0; + + /* Start nick tracking if available */ + if (NSNickTracking) + nsStartNickTracking(user); + + } else if (svid != 1) { + /* Resets the svid because it doesn't match */ + user->svid = 1; + + ircdproto->SendSVID(user->nick, user->timestamp); + + } else { + user->svid = 1; + } + send_event(EVENT_NEWNICK, 1, nick); + + } else { + /* An old user changing nicks. */ + if (UseTS6) + user = find_byuid(source); + + if (!user) + user = finduser(source); + + if (!user) { + alog("user: NICK from nonexistent nick %s", source); + return NULL; + } + user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ + if (debug) + alog("debug: %s changes nick to %s", source, nick); + + if (LogUsers) { + logrealname = normalizeBuffer(user->realname); + if (ircd->vhost) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), logrealname, nick, user->server->name); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", + user->nick, user->username, user->host, logrealname, + nick, user->server->name); + } + if (logrealname) { + free(logrealname); + } + } + + user->timestamp = ts; + + if (stricmp(nick, user->nick) == 0) { + /* No need to redo things */ user->SetNewNick(nick); - nc_changed = 0; - } else { - /* Update this only if nicks aren't the same */ - user->my_signon = time(NULL); - - old_na = user->na; - if (old_na) { - if (nick_recognized(user)) - user->na->last_seen = time(NULL); - status = old_na->status & NS_TRANSGROUP; - cancel_user(user); - } + nc_changed = 0; + } else { + /* Update this only if nicks aren't the same */ + user->my_signon = time(NULL); + + old_na = user->na; + if (old_na) { + if (nick_recognized(user)) + user->na->last_seen = time(NULL); + status = old_na->status & NS_TRANSGROUP; + cancel_user(user); + } user->SetNewNick(nick); - send_event(EVENT_CHANGE_NICK, 1, nick); - - if ((old_na ? old_na->nc : NULL) == - (user->na ? user->na->nc : NULL)) - nc_changed = 0; - - if (!nc_changed && (user->na)) - user->na->status |= status; - else { - ircdproto->SendUnregisteredNick(user); - } - } - - if (ircd->sqline) { - if (!is_oper(user) && check_sqline(user->nick, 1)) - return NULL; - } - - } /* if (!*source) */ - - /* Check for nick tracking to bypass identification */ - if (NSNickTracking && nsCheckNickTracking(user)) { - user->na->status |= NS_IDENTIFIED; - nc_changed = 0; - } - - if (nc_changed || !nick_recognized(user)) { - if (validate_user(user)) - check_memos(user); - - } else { - if (nick_identified(user)) { - char tsbuf[16]; - user->na->last_seen = time(NULL); - - if (user->na->last_usermask) - free(user->na->last_usermask); - user->na->last_usermask = - (char *)smalloc(strlen(common_get_vident(user)) + - strlen(common_get_vhost(user)) + 2); - sprintf(user->na->last_usermask, "%s@%s", - common_get_vident(user), common_get_vhost(user)); - - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) user->timestamp); - ircdproto->SendSVID2(user, tsbuf); - - alog("%s: %s!%s@%s automatically identified for nick %s", - s_NickServ, user->nick, user->username, - user->host, user->nick); - } - } - - /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ - if (ircd->check_nick_id) { - if (nick_identified(user)) { - char tsbuf[16]; - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) user->timestamp); - ircdproto->SendSVID3(user, tsbuf); - } - } - - return user; + send_event(EVENT_CHANGE_NICK, 1, nick); + + if ((old_na ? old_na->nc : NULL) == + (user->na ? user->na->nc : NULL)) + nc_changed = 0; + + if (!nc_changed && (user->na)) + user->na->status |= status; + else { + ircdproto->SendUnregisteredNick(user); + } + } + + if (ircd->sqline) { + if (!is_oper(user) && check_sqline(user->nick, 1)) + return NULL; + } + + } /* if (!*source) */ + + /* Check for nick tracking to bypass identification */ + if (NSNickTracking && nsCheckNickTracking(user)) { + user->na->status |= NS_IDENTIFIED; + nc_changed = 0; + } + + if (nc_changed || !nick_recognized(user)) { + if (validate_user(user)) + check_memos(user); + + } else { + if (nick_identified(user)) { + char tsbuf[16]; + user->na->last_seen = time(NULL); + + if (user->na->last_usermask) + free(user->na->last_usermask); + user->na->last_usermask = + (char *)smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", + common_get_vident(user), common_get_vhost(user)); + + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) user->timestamp); + ircdproto->SendSVID2(user, tsbuf); + + alog("%s: %s!%s@%s automatically identified for nick %s", + s_NickServ, user->nick, user->username, + user->host, user->nick); + } + } + + /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ + if (ircd->check_nick_id) { + if (nick_identified(user)) { + char tsbuf[16]; + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) user->timestamp); + ircdproto->SendSVID3(user, tsbuf); + } + } + + return user; } /*************************************************************************/ @@ -793,16 +793,16 @@ User *do_nick(const char *source, const char *nick, const char *username, const void do_umode(const char *source, int ac, const char **av) { - User *user; + User *user; - user = finduser(av[0]); - if (!user) { - alog("user: MODE %s for nonexistent nick %s: %s", av[1], av[0], - merge_args(ac, av)); - return; - } + user = finduser(av[0]); + if (!user) { + alog("user: MODE %s for nonexistent nick %s: %s", av[1], av[0], + merge_args(ac, av)); + return; + } - ircdproto->ProcessUsermodes(user, ac - 1, &av[1]); + ircdproto->ProcessUsermodes(user, ac - 1, &av[1]); } /* Handle a UMODE2 command for a user. @@ -811,16 +811,16 @@ void do_umode(const char *source, int ac, const char **av) void do_umode2(const char *source, int ac, const char **av) { - User *user; + User *user; - user = finduser(source); - if (!user) { - alog("user: MODE %s for nonexistent nick %s: %s", av[0], source, - merge_args(ac, av)); - return; - } + user = finduser(source); + if (!user) { + alog("user: MODE %s for nonexistent nick %s: %s", av[0], source, + merge_args(ac, av)); + return; + } - ircdproto->ProcessUsermodes(user, ac, &av[0]); + ircdproto->ProcessUsermodes(user, ac, &av[0]); } /*************************************************************************/ @@ -831,30 +831,30 @@ void do_umode2(const char *source, int ac, const char **av) void do_quit(const char *source, int ac, const char **av) { - User *user; - NickAlias *na; - - user = finduser(source); - if (!user) { - alog("user: QUIT from nonexistent user %s: %s", source, - merge_args(ac, av)); - return; - } - if (debug) { - alog("debug: %s quits", source); - } - if ((na = user->na) && (!(na->status & NS_VERBOTEN)) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { - na->last_seen = time(NULL); - if (na->last_quit) - free(na->last_quit); - na->last_quit = *av[0] ? sstrdup(av[0]) : NULL; - } - if (LimitSessions && !is_ulined(user->server->name)) { - del_session(user->host); - } - delete user; + User *user; + NickAlias *na; + + user = finduser(source); + if (!user) { + alog("user: QUIT from nonexistent user %s: %s", source, + merge_args(ac, av)); + return; + } + if (debug) { + alog("debug: %s quits", source); + } + if ((na = user->na) && (!(na->status & NS_VERBOTEN)) + && (!(na->nc->flags & NI_SUSPENDED)) + && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + na->last_seen = time(NULL); + if (na->last_quit) + free(na->last_quit); + na->last_quit = *av[0] ? sstrdup(av[0]) : NULL; + } + if (LimitSessions && !is_ulined(user->server->name)) { + del_session(user->host); + } + delete user; } /*************************************************************************/ @@ -866,32 +866,32 @@ void do_quit(const char *source, int ac, const char **av) void do_kill(const char *nick, const char *msg) { - User *user; - NickAlias *na; - - user = finduser(nick); - if (!user) { - if (debug) { - alog("debug: KILL of nonexistent nick: %s", nick); - } - return; - } - if (debug) { - alog("debug: %s killed", nick); - } - if ((na = user->na) && (!(na->status & NS_VERBOTEN)) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { - na->last_seen = time(NULL); - if (na->last_quit) - free(na->last_quit); - na->last_quit = *msg ? sstrdup(msg) : NULL; - - } - if (LimitSessions && !is_ulined(user->server->name)) { - del_session(user->host); - } - delete user; + User *user; + NickAlias *na; + + user = finduser(nick); + if (!user) { + if (debug) { + alog("debug: KILL of nonexistent nick: %s", nick); + } + return; + } + if (debug) { + alog("debug: %s killed", nick); + } + if ((na = user->na) && (!(na->status & NS_VERBOTEN)) + && (!(na->nc->flags & NI_SUSPENDED)) + && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + na->last_seen = time(NULL); + if (na->last_quit) + free(na->last_quit); + na->last_quit = *msg ? sstrdup(msg) : NULL; + + } + if (LimitSessions && !is_ulined(user->server->name)) { + del_session(user->host); + } + delete user; } /*************************************************************************/ @@ -901,11 +901,11 @@ void do_kill(const char *nick, const char *msg) int is_protected(User * user) { - if (ircd->protectedumode) { - return (user->mode & ircd->protectedumode); - } else { - return 0; - } + if (ircd->protectedumode) { + return (user->mode & ircd->protectedumode); + } else { + return 0; + } } /*************************************************************************/ @@ -914,11 +914,11 @@ int is_protected(User * user) int is_oper(User * user) |
