From 0d3ceb0f0ca7db062532240bf737176b17b287d6 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 29 Mar 2022 14:40:14 +0100 Subject: Hide disabled commands from /COMMANDS. --- src/modules/m_disable.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/modules/m_disable.cpp') diff --git a/src/modules/m_disable.cpp b/src/modules/m_disable.cpp index 984470bed..1e77a609b 100644 --- a/src/modules/m_disable.cpp +++ b/src/modules/m_disable.cpp @@ -23,7 +23,10 @@ enum { // From ircu. - ERR_DISABLED = 517 + ERR_DISABLED = 517, + + // InspIRCd-specific. + RPL_COMMANDS = 700 }; // Holds a list of disabled commands. @@ -122,6 +125,20 @@ public: notifyopers = tag->getBool("notifyopers"); } + ModResult OnNumeric(User* user, const Numeric::Numeric& numeric) override + { + if (numeric.GetNumeric() != RPL_COMMANDS || numeric.GetParams().size() < 1) + return MOD_RES_PASSTHRU; // The numeric isn't the one we care about. + + if (!fakenonexistent || !IS_LOCAL(user)) + return MOD_RES_PASSTHRU; // We're not hiding the numeric OR the user is remote. + + if (!stdalgo::isin(commands, numeric.GetParams()[0]) || user->HasPrivPermission("servers/use-disabled-commands")) + return MOD_RES_PASSTHRU; // Wrong command or the user is is an exempt oper. + + return MOD_RES_DENY; + } + ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override { // If a command is unvalidated or the source is not registered we do nothing. -- cgit v1.3.1-10-gc9f91