diff options
author | Matt Schatz <genius3000@g3k.solutions> | 2019-03-14 02:07:20 -0600 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-03-14 10:06:28 +0000 |
commit | b518f45d72e2c7bd38d4ecf155efbf4046c3f57c (patch) | |
tree | 57f39473c42c021325ae8365bbf56b5dadec68f7 | |
parent | 5f2ecf00132433c875c78b475ea46c8b73bf5f57 (diff) |
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.
-rw-r--r-- | src/mode.cpp | 10 |
1 files 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; } |