diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.c | 3 | ||||
-rw-r--r-- | src/chanserv.c | 10 | ||||
-rw-r--r-- | src/core/ms_cancel.c | 2 | ||||
-rw-r--r-- | src/core/ms_check.c | 2 | ||||
-rw-r--r-- | src/core/ns_group.c | 2 | ||||
-rw-r--r-- | src/core/ns_identify.c | 18 | ||||
-rw-r--r-- | src/core/ns_info.c | 3 | ||||
-rw-r--r-- | src/core/ns_logout.c | 4 | ||||
-rw-r--r-- | src/core/ns_register.c | 2 | ||||
-rw-r--r-- | src/core/ns_status.c | 2 | ||||
-rw-r--r-- | src/core/ns_suspend.c | 1 | ||||
-rw-r--r-- | src/core/ns_update.c | 1 | ||||
-rw-r--r-- | src/memoserv.c | 4 | ||||
-rw-r--r-- | src/nickserv.c | 67 | ||||
-rw-r--r-- | src/protocol/inspircd11.c | 2 | ||||
-rw-r--r-- | src/protocol/inspircd12.cpp | 2 | ||||
-rw-r--r-- | src/protocol/unreal32.c | 3 | ||||
-rw-r--r-- | src/servers.c | 2 | ||||
-rw-r--r-- | src/users.c | 64 |
19 files changed, 74 insertions, 120 deletions
diff --git a/src/channels.c b/src/channels.c index 29ab9f914..c7913a752 100644 --- a/src/channels.c +++ b/src/channels.c @@ -500,8 +500,7 @@ User *nc_on_chan(Channel * c, NickCore * nc) return NULL; for (u = c->users; u; u = u->next) { - if (u->user->nc == nc - && nick_recognized(u->user)) + if (u->user->nc == nc) return u->user; } return NULL; diff --git a/src/chanserv.c b/src/chanserv.c index 0d0914f69..819d3c03e 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -1169,7 +1169,7 @@ int check_kick(User * user, const char *chan, time_t chants) goto kick; } - if (nick_recognized(user)) + if (user->IsRecognized()) nc = user->nc; else nc = NULL; @@ -1869,7 +1869,7 @@ int is_founder(User * user, ChannelInfo * ci) if (user->nc && user->nc == ci->founder) { if ((nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) + || (user->IsRecognized() && !(ci->flags & CI_SECURE)))) return 1; } if (is_identified(user, ci)) @@ -1887,7 +1887,7 @@ int is_real_founder(User * user, ChannelInfo * ci) if (user->nc && user->nc == ci->founder) { if ((nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) + || (user->IsRecognized() && !(ci->flags & CI_SECURE)))) return 1; } return 0; @@ -1932,7 +1932,7 @@ int get_access(User * user, ChannelInfo * ci) return 0; if (nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE))) + || (user->IsRecognized() && !(ci->flags & CI_SECURE))) if ((access = ci->GetAccess(user->nc))) return access->level; @@ -1952,7 +1952,7 @@ void update_cs_lastseen(User * user, ChannelInfo * ci) return; if (is_founder(user, ci) || nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE))) + || (user->IsRecognized() && !(ci->flags & CI_SECURE))) if ((access = ci->GetAccess(user->nc))) access->last_seen = time(NULL); } diff --git a/src/core/ms_cancel.c b/src/core/ms_cancel.c index e52b21651..94e18262b 100644 --- a/src/core/ms_cancel.c +++ b/src/core/ms_cancel.c @@ -31,7 +31,7 @@ class CommandMSCancel : public Command const char *name = params[0].c_str(); MemoInfo *mi; - if (!nick_recognized(u)) + if (!u->IsRecognized()) notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { diff --git a/src/core/ms_check.c b/src/core/ms_check.c index 5b352deb1..ac48dac6d 100644 --- a/src/core/ms_check.c +++ b/src/core/ms_check.c @@ -31,7 +31,7 @@ class CommandMSCheck : public Command struct tm *tm; char timebuf[64]; - if (!nick_recognized(u)) + if (!u->IsRecognized()) { notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); return MOD_CONT; diff --git a/src/core/ns_group.c b/src/core/ns_group.c index ad25fc978..c3e458ed1 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -121,7 +121,6 @@ class CommandNSGroup : public Command sprintf(na->last_usermask, "%s@%s", u->GetIdent().c_str(), u->GetDisplayedHost().c_str()); na->last_realname = sstrdup(u->realname); na->time_registered = na->last_seen = time(NULL); - na->status = static_cast<int16>(NS_IDENTIFIED | NS_RECOGNIZED); u->nc = na->nc; @@ -243,6 +242,7 @@ NickAlias *makealias(const char *nick, NickCore *nc) na = new NickAlias; na->nick = sstrdup(nick); na->nc = nc; + na->status = 0; slist_add(&nc->aliases, na); alpha_insert_alias(na); return na; diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c index 4025acb16..9ae7f3a35 100644 --- a/src/core/ns_identify.c +++ b/src/core/ns_identify.c @@ -65,18 +65,10 @@ class CommandNSIdentify : public Command alog("%s: %s!%s@%s logged out of account %s", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, u->nc->display); } - if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) - { - if (na->last_usermask) - delete [] na->last_usermask; - na->last_usermask = new char[u->GetIdent().length() + u->GetDisplayedHost().length() + 2]; - sprintf(na->last_usermask, "%s@%s", u->GetIdent().c_str(), u->GetDisplayedHost().c_str()); - if (na->last_realname) - delete [] na->last_realname; - na->last_realname = sstrdup(u->realname); - } - - na->status |= NS_IDENTIFIED; + u->UpdateHost(); + if (na->last_realname) + delete [] na->last_realname; + na->last_realname = sstrdup(u->realname); na->last_seen = time(NULL); u->nc = na->nc; @@ -98,7 +90,7 @@ class CommandNSIdentify : public Command notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO); } - if (!(na->status & NS_RECOGNIZED)) + if (nick_identified(u)) check_memos(u); /* Clear any timers */ diff --git a/src/core/ns_info.c b/src/core/ns_info.c index 114f6b2e2..3e241b787 100644 --- a/src/core/ns_info.c +++ b/src/core/ns_info.c @@ -85,7 +85,7 @@ class CommandNSInfo : public Command time_t expt; /* Is the real owner of the nick we're looking up online? -TheShadow */ - if (na->status & (NS_RECOGNIZED | NS_IDENTIFIED)) + if (finduser(na->nick)) nick_online = 1; /* Only show hidden fields to owner and sadmins and only when the ALL @@ -95,7 +95,6 @@ class CommandNSInfo : public Command notice_lang(s_NickServ, u, NICK_INFO_REALNAME, na->nick, na->last_realname); - // XXX: we should perhaps show their opertype here. if (na->nc->IsServicesOper()) { if (show_hidden || (!(na->nc->flags & NI_HIDE_STATUS))) diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c index cb5ce25e0..d72753208 100644 --- a/src/core/ns_logout.c +++ b/src/core/ns_logout.c @@ -48,10 +48,6 @@ class CommandNSLogout : public Command cancel_user(u2); validate_user(u2); } - else if (na) - { - na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); - } if (ircd->modeonunreg) common_svsmode(u2, ircd->modeonunreg, "1"); diff --git a/src/core/ns_register.c b/src/core/ns_register.c index 886c879fa..ff16e5b33 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -37,7 +37,6 @@ class CommandNSConfirm : public Command char tmp_pass[PASSMAX]; memcpy(na->nc->pass, nr->password, PASSMAX); - na->status = static_cast<int16>(NS_IDENTIFIED | NS_RECOGNIZED); na->nc->flags |= NSDefFlags; @@ -430,6 +429,7 @@ NickAlias *makenick(const char *nick) na = new NickAlias; na->nick = sstrdup(nick); na->nc = nc; + na->status = 0; slist_add(&nc->aliases, na); alpha_insert_alias(na); return na; diff --git a/src/core/ns_status.c b/src/core/ns_status.c index 92913a30b..e8f99fa78 100644 --- a/src/core/ns_status.c +++ b/src/core/ns_status.c @@ -43,7 +43,7 @@ class CommandNSStatus : public Command notice_lang(s_NickServ, u, NICK_STATUS_REPLY, nick, 0, ""); else if (nick_identified(u2) && na && na->nc == u2->nc) /* Nick is identified */ notice_lang(s_NickServ, u, NICK_STATUS_REPLY, nick, 3, u2->nc->display); - else if (nick_recognized(u2)) /* Nick is recognised, but NOT identified */ + else if (u2->IsRecognized()) /* Nick is recognised, but NOT identified */ notice_lang(s_NickServ, u, NICK_STATUS_REPLY, nick, 2, (u2->nc ? u2->nc->display : "")); else if (!na) /* Nick is online, but NOT a registered */ notice_lang(s_NickServ, u, NICK_STATUS_REPLY, nick, 0, ""); diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c index 3e1b5ba4f..0b1adcf2e 100644 --- a/src/core/ns_suspend.c +++ b/src/core/ns_suspend.c @@ -65,7 +65,6 @@ class CommandNSSuspend : public Command na2 = static_cast<NickAlias *>(na->nc->aliases.list[i]); if (na2->nc == na->nc) { - na2->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); if (na2->last_quit) delete [] na2->last_quit; na2->last_quit = sstrdup(reason); diff --git a/src/core/ns_update.c b/src/core/ns_update.c index dc2de462c..9b18a4596 100644 --- a/src/core/ns_update.c +++ b/src/core/ns_update.c @@ -35,7 +35,6 @@ class CommandNSUpdate : public Command if (na->last_realname) delete [] na->last_realname; na->last_realname = sstrdup(u->realname); - na->status |= NS_IDENTIFIED; na->last_seen = time(NULL); if (ircd->vhost) do_on_id(u); diff --git a/src/memoserv.c b/src/memoserv.c index aef802bc3..5a32cfec2 100644 --- a/src/memoserv.c +++ b/src/memoserv.c @@ -90,7 +90,7 @@ void check_memos(User * u) return; } - if (!(nc = u->nc) || !nick_recognized(u) || + if (!(nc = u->nc) || !u->IsRecognized() || !(nc->flags & NI_MEMO_SIGNON)) { return; } @@ -211,7 +211,7 @@ void memo_send(User * u, const char *name, const char *text, int z) if (z == 3) syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); - } else if (!nick_recognized(u)) { + } else if (!u->IsRecognized()) { if (z == 0 || z == 3) notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); diff --git a/src/nickserv.c b/src/nickserv.c index 01c90a07e..1dbba0671 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -56,9 +56,10 @@ class NickServCollide : public Timer void Tick(time_t ctime) { /* If they identified or don't exist anymore, don't kill them. */ - if ((na->status & NS_IDENTIFIED) || !finduser(na->nick) - || finduser(na->nick)->my_signon > this->GetSetTime()) + User *u = finduser(na->nick); + if (!u || !nick_identified(u) || u->my_signon > this->GetSetTime()) return; + /* The RELEASE timeout will always add to the beginning of the * list, so we won't see it. Which is fine because it can't be * triggered yet anyway. */ @@ -622,8 +623,6 @@ int validate_user(User * u) NickRequest *nr; NickServCollide *t; - int on_access; - if ((nr = findrequestnick(u->nick))) { notice_lang(s_NickServ, u, NICK_IS_PREREG); @@ -646,13 +645,8 @@ int validate_user(User * u) return 0; } - on_access = is_on_access(u, na->nc); - if (on_access) - na->status |= NS_ON_ACCESS; - - if (!(na->nc->flags & NI_SECURE) && on_access) + if (!(na->nc->flags & NI_SECURE) && u->IsRecognized()) { - na->status |= NS_RECOGNIZED; na->last_seen = time(NULL); if (na->last_usermask) delete [] na->last_usermask; @@ -665,7 +659,7 @@ int validate_user(User * u) return 1; } - if (on_access || !(na->nc->flags & NI_KILL_IMMED)) + if (u->IsRecognized() || !(na->nc->flags & NI_KILL_IMMED)) { if (na->nc->flags & NI_SECURE) notice_lang(s_NickServ, u, NICK_IS_SECURE, s_NickServ); @@ -673,7 +667,7 @@ int validate_user(User * u) notice_lang(s_NickServ, u, NICK_IS_REGISTERED, s_NickServ); } - if ((na->nc->flags & NI_KILLPROTECT) && !on_access) + if ((na->nc->flags & NI_KILLPROTECT) && !u->IsRecognized()) { if (na->nc->flags & NI_KILL_IMMED) { @@ -753,34 +747,6 @@ int nick_identified(User * u) /*************************************************************************/ -/* Return whether a user is recognized for their nickname. */ - -int nick_recognized(User * u) -{ - if (u) - { - NickAlias *na = findnick(u->nick); - if (na) - { - if (na->status) - { - return (na->status & (NS_IDENTIFIED | NS_RECOGNIZED)); - } - else - { - return 0; - } - } - else - { - return 0; - } - } - return 0; -} - -/*************************************************************************/ - /* Remove all nicks which have expired. Also update last-seen time for all * nicks. */ @@ -799,8 +765,7 @@ void expire_nicks() next = na->next; User *u = finduser(na->nick); - if (u - && ((na->nc->flags & NI_SECURE) ? nick_identified(u) : nick_recognized(u))) + if (u && ((na->nc->flags & NI_SECURE) ? nick_identified(u) : u->IsRecognized())) { if (debug >= 2) alog("debug: NickServ: updating last seen time for %s", @@ -941,18 +906,20 @@ NickCore *findcore(const char *nick) /*********************** NickServ private routines ***********************/ /*************************************************************************/ -/* Is the given user's address on the given nick's access list? Return 1 - * if so, 0 if not. */ - -int is_on_access(User * u, NickCore * nc) +/** Is the user's address on the nickcores access list? + * @param u The user + * @param nc The nickcore + * @return true or false + */ +bool is_on_access(User *u, NickCore *nc) { unsigned i; char *buf; char *buf2 = NULL; char *buf3 = NULL; - if (nc->access.empty()) - return 0; + if (!u || !nc || nc->access.empty()) + return false; buf = new char[u->GetIdent().length() + strlen(u->host) + 2]; sprintf(buf, "%s@%s", u->GetIdent().c_str(), u->host); @@ -987,7 +954,7 @@ int is_on_access(User * u, NickCore * nc) delete [] buf3; } } - return 1; + return true; } } delete [] buf; @@ -996,7 +963,7 @@ int is_on_access(User * u, NickCore * nc) delete [] buf2; delete [] buf3; } - return 0; + return false; } /*************************************************************************/ diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index cc8b7f73f..93574f8df 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -485,7 +485,7 @@ class InspIRCdProto : public IRCDProto delete [] user->vhost; user->vhost = NULL; } - update_host(user); + user->UpdateHost(); } } } diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 25da3e324..5066d77dd 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -495,7 +495,7 @@ class InspIRCdProto : public IRCDProto delete [] user->vhost; user->vhost = NULL; } - update_host(user); + user->UpdateHost(); } } } diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 78d888518..2223cd162 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -600,7 +600,7 @@ class UnrealIRCdProto : public IRCDProto delete [] user->vhost; user->vhost = NULL; } - update_host(user); + user->UpdateHost(); break; default: break; @@ -1426,7 +1426,6 @@ int anope_event_userhost(const char *source, int ac, const char **av) if (u) { u->SetCloakedHost(host); - update_host(u); } return MOD_CONT; diff --git a/src/servers.c b/src/servers.c index 04e04486a..cb5163c77 100644 --- a/src/servers.c +++ b/src/servers.c @@ -219,7 +219,7 @@ static void delete_server(Server * serv, const char *quitreason) { if ((na = findnick(u->nick)) && !(na->status & NS_FORBIDDEN) && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + && (u->IsRecognized() || nick_identified(u))) { na->last_seen = time(NULL); if (na->last_quit) delete [] na->last_quit; diff --git a/src/users.c b/src/users.c index 76e108154..08c4d81f8 100644 --- a/src/users.c +++ b/src/users.c @@ -30,7 +30,7 @@ time_t maxusertime; User::User(const std::string &snick, const std::string &suid) { User **list; - // XXX: we could do well to steal CoreException from insp + if (snick.empty()) throw "what the craq, empty nick passed to constructor"; @@ -45,6 +45,7 @@ User::User(const std::string &snick, const std::string &suid) chans = NULL; founder_chans = NULL; invalid_pw_count = timestamp = my_signon = mode = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0; + OnAccess = false; strscpy(this->nick, snick.c_str(), NICKMAX); this->uid = suid; @@ -100,6 +101,11 @@ void User::SetNewNick(const std::string &newnick) if (*list) (*list)->prev = this; *list = this; + + OnAccess = false; + NickAlias *na = findnick(this->nick); + if (na) + OnAccess = is_on_access(this, na->nc); } void User::SetDisplayedHost(const std::string &shost) @@ -114,7 +120,7 @@ void User::SetDisplayedHost(const std::string &shost) if (debug) alog("debug: %s changed vhost to %s", this->nick, shost.c_str()); - update_host(this); + this->UpdateHost(); } /** Get the displayed vhost of a user record. @@ -143,7 +149,7 @@ void User::SetCloakedHost(const std::string &newhost) if (debug) alog("debug: %s changed cloaked host to %s", this->nick, newhost.c_str()); - update_host(this); + this->UpdateHost(); } /** Get the cloaked host of a user @@ -167,7 +173,7 @@ void User::SetVIdent(const std::string &sident) if (debug) alog("debug: %s changed ident to %s", this->nick, sident.c_str()); - update_host(this); + this->UpdateHost(); } const std::string &User::GetVIdent() const @@ -187,7 +193,7 @@ void User::SetIdent(const std::string &sident) if (debug) alog("debug: %s changed real ident to %s", this->nick, sident.c_str()); - update_host(this); + this->UpdateHost(); } const std::string &User::GetIdent() const @@ -206,7 +212,7 @@ void User::SetRealname(const std::string &srealname) this->realname = sstrdup(srealname.c_str()); NickAlias *na = findnick(this->nick); - if (na && (nick_identified(this) || (!this->nc || (this->nc && !(this->nc->flags & NI_SECURE) && nick_recognized(this))))) + if (na && (nick_identified(this) || (!this->nc || (this->nc && !(this->nc->flags & NI_SECURE) && IsRecognized())))) { if (na->last_realname) delete [] na->last_realname; @@ -358,7 +364,6 @@ void User::CheckAuthenticationToken(const char *svid) if (svid && c && !strcmp(svid, c)) { /* Users authentication token matches so they should become identified */ - na->status |= NS_IDENTIFIED; check_memos(this); this->nc = na->nc; } @@ -379,38 +384,40 @@ void User::AutoID(const char *account) this->nc = tnc; if ((na = findnick(this->nick)) && na->nc == tnc) { - na->status |= NS_IDENTIFIED; check_memos(this); } } } -/*************************************************************************/ -/*************************************************************************/ +/** Check if the user is recognized for their nick (on the nicks access list) + * @return true or false + */ +const bool User::IsRecognized() const +{ + return OnAccess; +} -/* - * XXX: I don't like how this "smells". I think it belongs in NickAlias/NickCore. - * -- w00t +/** Update the last usermask stored for a user, and check to see if they are recognized */ -void update_host(User * user) +void User::UpdateHost() { - NickCore *nc = findcore(user->nick); - if (nick_identified(user) || (nc && !(nc->flags & NI_SECURE) && nick_recognized(user))) - { - NickAlias *na = findnick(user->nick); + NickAlias *na = findnick(this->nick); + if (nick_identified(this) || (na && !(na->nc->flags & NI_SECURE) && IsRecognized())) + { if (na->last_usermask) delete [] na->last_usermask; - na->last_usermask = new char[user->GetIdent().length() + user->GetDisplayedHost().length() + 2]; - sprintf(na->last_usermask, "%s@%s", user->GetIdent().c_str(), - user->GetDisplayedHost().c_str()); + na->last_usermask = new char[this->GetIdent().length() + this->GetDisplayedHost().length() + 2]; + sprintf(na->last_usermask, "%s@%s", this->GetIdent().c_str(), this->GetDisplayedHost().c_str()); } + + OnAccess = false; + if (na && this->host) + OnAccess = is_on_access(this, na->nc); } /*************************************************************************/ -/*************************************************************************/ -/*************************************************************************/ /* Return statistics. Pointers are assumed to be valid. */ @@ -753,7 +760,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const old_na = findnick(user->nick); if (old_na) { - if (nick_recognized(user)) + if (user->IsRecognized()) old_na->last_seen = time(NULL); status = old_na->status & NS_TRANSGROUP; cancel_user(user); @@ -780,7 +787,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const } else { - if (!nick_identified(user) || !nick_recognized(user)) + if (!nick_identified(user) || !user->IsRecognized()) { ircdproto->SendUnregisteredNick(user); } @@ -803,7 +810,6 @@ User *do_nick(const char *source, const char *nick, const char *username, const NickAlias *ntmp = findnick(user->nick); if (ntmp && user->nc == ntmp->nc) { - ntmp->status |= NS_IDENTIFIED; nc_changed = 0; } @@ -880,8 +886,7 @@ void do_quit(const char *source, int ac, const char **av) alog("debug: %s quits", source); } if ((na = findnick(user->nick)) && (!(na->status & NS_FORBIDDEN)) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + && (!(na->nc->flags & NI_SUSPENDED)) && (user->IsRecognized() || nick_identified(user))) { na->last_seen = time(NULL); if (na->last_quit) delete [] na->last_quit; @@ -916,8 +921,7 @@ void do_kill(const char *nick, const char *msg) alog("debug: %s killed", nick); } if ((na = findnick(user->nick)) && (!(na->status & NS_FORBIDDEN)) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + && (!(na->nc->flags & NI_SUSPENDED)) && (user->IsRecognized() || nick_identified(user))) { na->last_seen = time(NULL); if (na->last_quit) delete [] na->last_quit; |