diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.c | 6 | ||||
-rw-r--r-- | src/channels.c | 4 | ||||
-rw-r--r-- | src/core/cs_ban.c | 4 | ||||
-rw-r--r-- | src/core/cs_kick.c | 4 | ||||
-rw-r--r-- | src/core/cs_modes.c | 2 | ||||
-rw-r--r-- | src/modules/cs_tban.c | 2 | ||||
-rw-r--r-- | src/regchannel.cpp | 54 | ||||
-rw-r--r-- | src/users.c | 23 |
8 files changed, 54 insertions, 45 deletions
diff --git a/src/botserv.c b/src/botserv.c index 05c8ea2bd..d0862c119 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -723,7 +723,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, const char *rea if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) { - if (is_protected(u) && (requester != u)) { + if (u->IsProtected() && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name.c_str(), "%s", getstring(ACCESS_DENIED)); return; } @@ -764,7 +764,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, const char *re if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) { - if (is_protected(u) && (requester != u)) { + if (u->IsProtected() && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name.c_str(), "%s", getstring(ACCESS_DENIED)); return; } @@ -797,7 +797,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, char *ni snprintf(buf, BUFSIZE - 1, "%ld", static_cast<long>(time(NULL))); if ((ModeManager::FindUserModeByName(UMODE_PROTECTED))) { - if (is_protected(u) && *mode == '-' && (requester != u)) { + if (u->IsProtected() && *mode == '-' && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name.c_str(), "%s", getstring(ACCESS_DENIED)); return; } diff --git a/src/channels.c b/src/channels.c index 557894eff..a4cf3b167 100644 --- a/src/channels.c +++ b/src/channels.c @@ -977,6 +977,10 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) /* May not kick ulines */ if (u->server->IsULined()) return false; + + /* Do not kick protected clients */ + if (u->IsProtected()) + return false; EventReturn MOD_RESULT; FOREACH_RESULT(I_OnBotKick, OnBotKick(bi, this, u, buf)); diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index bacc8dff8..95c5c6556 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -62,9 +62,9 @@ class CommandCSBan : public Command */ } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(ci, u2)) { notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); - } else if (is_protected(u2)) { + } else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else { + else { char mask[BUFSIZE]; get_idealban(ci, u2, mask, sizeof(mask)); diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c index 9614c8cc3..42059a01b 100644 --- a/src/core/cs_kick.c +++ b/src/core/cs_kick.c @@ -56,9 +56,9 @@ class CommandCSKick : public Command } else if (!is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (is_protected(u2)) { + } else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (!c->FindUser(u2)) { + else if (!c->FindUser(u2)) { notice_lang(Config.s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick.c_str(), c->name.c_str()); } else { if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index 06e737eff..788c1adac 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -49,7 +49,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (!set && !is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - else if (!set && is_protected(u2) && !is_same) + else if (!set && u2->IsProtected() && !is_same) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (!c->FindUser(u2)) notice_lang(Config.s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick.c_str(), c->name.c_str()); diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 10f295b3d..12fe8cd65 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -203,7 +203,7 @@ int canBanUser(Channel * c, User * u, User * u2) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (is_excepted(ci, u2)) notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); - else if (is_protected(u2)) + else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else ok = 1; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index d70985f9c..39feed45a 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -564,7 +564,7 @@ void ChannelInfo::ClearParams() */ bool ChannelInfo::CheckKick(User *user) { - AutoKick *akick; + AutoKick *autokick; bool set_modes = false, do_kick = false; NickCore *nc; char mask[BUFSIZE]; @@ -573,7 +573,7 @@ bool ChannelInfo::CheckKick(User *user) if (!user || !this->c) return false; - if (user->isSuperAdmin == 1) + if (user->isSuperAdmin) return false; /* We don't enforce services restrictions on clients on ulined services @@ -589,34 +589,40 @@ bool ChannelInfo::CheckKick(User *user) do_kick = true; } + if (!do_kick && user->IsProtected()) + return false; + + if (!do_kick && ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(this, user) == 1) + return false; + if (user->Account() || user->IsRecognized()) nc = user->Account(); else nc = NULL; - if (!do_kick && ModeManager::FindChannelModeByName(CMODE_EXCEPT) && is_excepted(this, user) == 1) - return false; - - for (unsigned j = 0; j < this->GetAkickCount(); ++j) + if (!do_kick) { - akick = this->GetAkick(j); - - if (!akick->InUse || do_kick) - continue; - - if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) - || (!akick->HasFlag(AK_ISNICK) - && match_usermask(akick->mask.c_str(), user))) + for (unsigned j = 0; j < this->GetAkickCount(); ++j) { - Alog(LOG_DEBUG_2) << user->nick << " matched akick " << (akick->HasFlag(AK_ISNICK) ? -akick->nc->display : akick->mask); - akick->last_used = time(NULL); - if (akick->HasFlag(AK_ISNICK)) - get_idealban(this, user, mask, sizeof(mask)); - else - strlcpy(mask, akick->mask.c_str(), sizeof(mask)); - reason = !akick->reason.empty() ? akick->reason.c_str() : Config.CSAutokickReason; - do_kick = true; + autokick = this->GetAkick(j); + + if (!autokick->InUse) + continue; + + if ((autokick->HasFlag(AK_ISNICK) && autokick->nc == nc) + || (!autokick->HasFlag(AK_ISNICK) + && match_usermask(autokick->mask.c_str(), user))) + { + Alog(LOG_DEBUG_2) << user->nick << " matched akick " << (autokick->HasFlag(AK_ISNICK) ? autokick->nc->display : autokick->mask); + autokick->last_used = time(NULL); + if (autokick->HasFlag(AK_ISNICK)) + get_idealban(this, user, mask, sizeof(mask)); + else + strlcpy(mask, autokick->mask.c_str(), sizeof(mask)); + reason = !autokick->reason.empty() ? autokick->reason.c_str() : Config.CSAutokickReason; + do_kick = true; + break; + } } } @@ -631,7 +637,7 @@ akick->nc->display : akick->mask); if (!do_kick) return false; - Alog(LOG_DEBUG) << "channel: Autokicking "<< user->GetMask() << " from " << this->name; + Alog(LOG_DEBUG) << "Autokicking "<< user->GetMask() << " from " << this->name; /* If the channel isn't syncing and doesn't have any users, join ChanServ * NOTE: we use usercount == 1 here as there is one user, but they are about to be destroyed diff --git a/src/users.c b/src/users.c index 6e42b7a08..744177e5a 100644 --- a/src/users.c +++ b/src/users.c @@ -755,6 +755,17 @@ ChannelContainer *User::FindChannel(Channel *c) return NULL; } +/** Check if the user is protected from kicks and negative mode changes + * @return true or false + */ +bool User::IsProtected() const +{ + if (this->HasMode(UMODE_PROTECTED) || this->HasMode(UMODE_GOD)) + return true; + + return false; +} + /*************************************************************************/ /* Iterate over all users in the user list. Return NULL at end of list. */ @@ -1096,18 +1107,6 @@ void do_kill(const std::string &nick, const std::string &msg) /*************************************************************************/ /*************************************************************************/ -/* Is the given user protected from kicks and negative mode changes? */ - -int is_protected(User * user) -{ - if (user && user->HasMode(UMODE_PROTECTED)) - return 1; - - return 0; -} - -/*************************************************************************/ - /* Is the given nick an oper? */ int is_oper(User * user) |