From b518f45d72e2c7bd38d4ecf155efbf4046c3f57c Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Thu, 14 Mar 2019 02:07:20 -0600 Subject: Check perms for removal of oper-only channel modes. Oper-only channel modes are currently unsettable by any channel op, oper or not. Correct this by checking both directions of an oper-only channel mode and continue only checking the setting of an oper-only user mode. As anyone should be able to unset their own user modes and UnOper() removes all oper-only user modes automatically. --- src/mode.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mode.cpp b/src/mode.cpp index 6f17d3896..7a0afdd03 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -312,18 +312,18 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode } } - if ((adding) && (IS_LOCAL(user)) && (mh->NeedsOper()) && (!user->HasModePermission(mh))) + if ((chan || (!chan && adding)) && IS_LOCAL(user) && mh->NeedsOper() && !user->HasModePermission(mh)) { /* It's an oper only mode, and they don't have access to it. */ if (user->IsOper()) { - user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to set %s mode %c", - user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); + user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to %sset %s mode %c", + user->oper->name.c_str(), adding ? "" : "un", type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); } else { - user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Only operators may set %s mode %c", - type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); + user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Only operators may %sset %s mode %c", + adding ? "" : "un", type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); } return MODEACTION_DENY; } -- cgit v1.2.3