diff options
| author | 2026-03-08 20:33:49 +0000 | |
|---|---|---|
| committer | 2026-03-08 20:33:49 +0000 | |
| commit | 7a816085dc3bdcd6141df9b946c78a6963ff89c1 (patch) | |
| tree | f7c23cf995d891004ba78805f77cfecf6319b2e3 /modules/setname.cpp | |
| parent | Make the ban checking functions able to check any list mode. (diff) | |
| parent | Respect <security:restrictbannedusers> in setname. (diff) | |
Merge branch 'insp4' into master.
Diffstat (limited to 'modules/setname.cpp')
| -rw-r--r-- | modules/setname.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/setname.cpp b/modules/setname.cpp index ea50ff29e..88bf27ae3 100644 --- a/modules/setname.cpp +++ b/modules/setname.cpp @@ -31,11 +31,13 @@ class CommandSetName final : public Command { public: + ChanModeReference banmode; Cap::Capability cap; bool notifyopers; CommandSetName(Module* mod) : Command(mod, "SETNAME", 1, 2) + , banmode(mod, "ban") , cap(mod, "setname") { syntax = { "[<nick>] :<newreal>" }; @@ -80,6 +82,24 @@ public: return CmdResult::FAILURE; } + // Disallow the real name change if <security:restrictbannedusers> is on and there is a ban + // matching this user in one of the channels they are on. + if (target == user && ServerInstance->Config->RestrictBannedUsers != ServerConfig::BUT_NORMAL) + { + for (const auto* memb : user->chans) + { + if (memb->chan->GetPrefixValue(user) < VOICE_VALUE && memb->chan->CheckList(*banmode, user)) + { + if (ServerInstance->Config->RestrictBannedUsers == ServerConfig::BUT_RESTRICT_NOTIFY) + { + IRCv3::WriteReply(Reply::FAIL, user, &cap, this, "CANNOT_CHANGE_REALNAME", + FMT::format("Cannot change nickname while on {} (you're banned)", memb->chan->name)); + } + return CmdResult::FAILURE; + } + } + } + target->ChangeRealName(newreal); if (notifyopers || user != target) { |
