From 4fb31d6a3494a99819225fe36da75c5991461dc6 Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Thu, 30 Sep 2010 19:03:06 -0400 Subject: Fix kick level check to scan all status modes and not skip checks for modeless users --- src/channels.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/channels.cpp') diff --git a/src/channels.cpp b/src/channels.cpp index 5779fb50b..8e7d4af06 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -523,16 +523,21 @@ void Channel::KickUser(User *src, User *user, const char* reason) if (res == MOD_RES_DENY) return; - if (res == MOD_RES_PASSTHRU && !memb->modes.empty()) + if (res == MOD_RES_PASSTHRU) { - int them = this->GetPrefixValue(src); - char us = memb->modes[0]; - ModeHandler* mh = ServerInstance->Modes->FindMode(us, MODETYPE_CHANNEL); - int min = mh ? mh->GetLevelRequired() : HALFOP_VALUE; - if (them < HALFOP_VALUE || them < min) + unsigned int them = this->GetPrefixValue(src); + unsigned int req = HALFOP_VALUE; + for (std::string::size_type i = 0; i < memb->modes.length(); i++) + { + ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL); + if (mh && mh->GetLevelRequired() > req) + req = mh->GetLevelRequired(); + } + + if (them < req) { src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator", - src->nick.c_str(), this->name.c_str(), min > HALFOP_VALUE ? "" : "half-"); + src->nick.c_str(), this->name.c_str(), req > HALFOP_VALUE ? "" : "half-"); return; } } -- cgit v1.2.3