diff options
| author | 2022-11-27 07:32:42 +0000 | |
|---|---|---|
| committer | 2022-11-28 02:57:50 +0000 | |
| commit | ee44af8d04f23b4a16c9b377764f930d69e575f7 (patch) | |
| tree | 4348a9d4b76ea65266875651d57d2ebf3e1d7894 /src/modules/m_check.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
| download | inspircd++-ee44af8d04f23b4a16c9b377764f930d69e575f7.tar.gz inspircd++-ee44af8d04f23b4a16c9b377764f930d69e575f7.tar.bz2 inspircd++-ee44af8d04f23b4a16c9b377764f930d69e575f7.zip | |
Refactor the internals of the oper system.
- Allow overriding privileges from the <class> blocks in the <type>
and <oper> blocks.
- Separate oper types from oper accounts in the code. This enables
moving some core stuff out of the config tag later.
- Merge the config tags together to make a synthetic tag that can
have getXXX called on it instead of using getConfig and then
converting it.
- Move the details of Have*Permission into the oper type class.
- Improve oper events to allow modules to easily hook into the oper
system.
Diffstat (limited to 'src/modules/m_check.cpp')
| -rw-r--r-- | src/modules/m_check.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index c924f55e5..10ec6ca4b 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -134,6 +134,19 @@ class CommandCheck final return ret; } + static std::string GetAllowedOperOnlyCommands(LocalUser* user) + { + std::string ret; + for (const auto& [_, cmd] : ServerInstance->Parser.GetCommands()) + { + if (cmd->access_needed == CmdAccess::OPERATOR && user->HasCommandPermission(cmd->name)) + ret += cmd->name + " "; + } + if (!ret.empty()) + ret.pop_back(); + return ret; + } + static std::string GetAllowedOperOnlyModes(LocalUser* user, ModeType modetype) { std::string ret; @@ -209,15 +222,15 @@ public: if (targetuser->IsOper()) { - /* user is an oper of type ____ */ - context.Write("opertype", targetuser->oper->name); + context.Write("oper", targetuser->oper->GetName()); + context.Write("opertype", targetuser->oper->GetType()); if (localtarget) { context.Write("chanmodeperms", GetAllowedOperOnlyModes(localtarget, MODETYPE_CHANNEL)); context.Write("usermodeperms", GetAllowedOperOnlyModes(localtarget, MODETYPE_USER)); context.Write("snomaskperms", GetAllowedOperOnlySnomasks(localtarget)); - context.Write("commandperms", targetuser->oper->AllowedOperCommands.ToString()); - context.Write("permissions", targetuser->oper->AllowedPrivs.ToString()); + context.Write("commandperms", GetAllowedOperOnlyCommands(localtarget)); + context.Write("permissions", localtarget->oper->GetPrivileges()); } } |
