diff options
author | Adam <Adam@anope.org> | 2010-07-10 22:50:18 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-07-10 22:50:18 -0400 |
commit | 63d71424650ac697f2e698c1c8fd242729691a0f (patch) | |
tree | 9c55ed88e580056540f9c728590a50cca7b39404 | |
parent | a49521302628982f62ddadd997a81734f4d8c84f (diff) |
Added options:hideprivilegedcommands config option to hide privileged commands from normal users
-rw-r--r-- | data/example.conf | 6 | ||||
-rw-r--r-- | docs/Changes.conf | 1 | ||||
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | src/commands.cpp | 2 | ||||
-rw-r--r-- | src/config.cpp | 1 | ||||
-rw-r--r-- | src/core/bs_help.cpp | 3 | ||||
-rw-r--r-- | src/core/cs_help.cpp | 3 | ||||
-rw-r--r-- | src/core/hs_help.cpp | 3 | ||||
-rw-r--r-- | src/core/ms_help.cpp | 3 | ||||
-rw-r--r-- | src/core/ns_help.cpp | 3 | ||||
-rw-r--r-- | src/core/os_help.cpp | 3 |
11 files changed, 23 insertions, 7 deletions
diff --git a/data/example.conf b/data/example.conf index 6c5c87bc7..93a265051 100644 --- a/data/example.conf +++ b/data/example.conf @@ -572,6 +572,12 @@ options * How long to wait between connection retries, in seconds. */ retrywait = 60 + + /* + * If set, Services will hide commands that users doesn't have the privilege to execute + * from HELP output. + */ + hideprivilegedcommands = no } diff --git a/docs/Changes.conf b/docs/Changes.conf index 8cc990c3a..404a06bc2 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -10,6 +10,7 @@ chanserv:modules added many new cs_set_command modules opertype:commands added nickserv/saset/* and chanserv/saset/* options:socketengine added to choose what socket engine to use module:cs_set_misc and module:ns_set_misc added to replace the old set url/icq/email modules +options:hideprivilegedcommands added to hide privileged commands from normal users ** MODIFIED CONFIGURATION DIRECTIVES ** opertype:commands changed operserv/sgline to opserv/snline diff --git a/include/config.h b/include/config.h index 8b1d42527..34315e3c8 100644 --- a/include/config.h +++ b/include/config.h @@ -555,6 +555,8 @@ class ServerConfig unsigned MaxRetries; /* How long to wait between connection attempts */ int RetryWait; + /* If services should hide unprivileged commands */ + bool HidePrivilegedCommands; /* Services can use email */ bool UseMail; diff --git a/src/commands.cpp b/src/commands.cpp index 7396968c4..ebe189fd4 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -167,7 +167,7 @@ void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd) ci::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining().c_str(); - if (!c || !c->OnHelp(u, subcommand)) + if (!c || (Config.HidePrivilegedCommands && !c->permission.empty() && (!u->Account() || !u->Account()->HasCommand(c->permission))) || !c->OnHelp(u, subcommand)) notice_lang(bi->nick, u, NO_HELP_AVAILABLE, cmd.c_str()); else { diff --git a/src/config.cpp b/src/config.cpp index 5785c4452..61f9d586f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -664,6 +664,7 @@ int ServerConfig::Read(bool bail) {"options", "botmodes", "", new ValueContainerCIString(&Config.BotModes), DT_CISTRING, NoValidation}, {"options", "maxretries", "10", new ValueContainerUInt(&Config.MaxRetries), DT_UINTEGER, NoValidation}, {"options", "retrywait", "60", new ValueContainerInt(&Config.RetryWait), DT_INTEGER, ValidateNotZero}, + {"options", "hideprivilegedcommands", "no", new ValueContainerBool(&Config.HidePrivilegedCommands), DT_BOOLEAN, ValidateEmailReg}, {"nickserv", "nick", "NickServ", new ValueContainerChar(&Config.s_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, {"nickserv", "description", "Nickname Registration Service", new ValueContainerChar(&Config.desc_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, {"nickserv", "emailregistration", "no", new ValueContainerBool(&Config.NSEmailReg), DT_BOOLEAN, NoValidation}, diff --git a/src/core/bs_help.cpp b/src/core/bs_help.cpp index 694318187..7183c6fe9 100644 --- a/src/core/bs_help.cpp +++ b/src/core/bs_help.cpp @@ -33,7 +33,8 @@ class CommandBSHelp : public Command // Abuse syntax error to display general list help. notice_help(Config.s_BotServ, u, BOT_HELP); for (CommandMap::const_iterator it = BotServ->Commands.begin(), it_end = BotServ->Commands.end(); it != it_end; ++it) - it->second->OnServHelp(u); + if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission))) + it->second->OnServHelp(u); notice_help(Config.s_BotServ, u, BOT_HELP_FOOTER, Config.BSMinUsers); } }; diff --git a/src/core/cs_help.cpp b/src/core/cs_help.cpp index f655752e6..536a6e423 100644 --- a/src/core/cs_help.cpp +++ b/src/core/cs_help.cpp @@ -50,7 +50,8 @@ class CommandCSHelp : public Command { notice_help(Config.s_ChanServ, u, CHAN_HELP); for (CommandMap::const_iterator it = ChanServ->Commands.begin(); it != ChanServ->Commands.end(); ++it) - it->second->OnServHelp(u); + if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission))) + it->second->OnServHelp(u); if (Config.CSExpire >= 86400) notice_help(Config.s_ChanServ, u, CHAN_HELP_EXPIRES, Config.CSExpire / 86400); if (u->Account() && u->Account()->IsServicesOper()) diff --git a/src/core/hs_help.cpp b/src/core/hs_help.cpp index 507f887ed..b4b20e149 100644 --- a/src/core/hs_help.cpp +++ b/src/core/hs_help.cpp @@ -31,7 +31,8 @@ class CommandHSHelp : public Command { notice_help(Config.s_HostServ, u, HOST_HELP, Config.s_HostServ); for (CommandMap::const_iterator it = HostServ->Commands.begin(), it_end = HostServ->Commands.end(); it != it_end; ++it) - it->second->OnServHelp(u); + if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission))) + it->second->OnServHelp(u); } }; diff --git a/src/core/ms_help.cpp b/src/core/ms_help.cpp index f2646904c..41cdaafb3 100644 --- a/src/core/ms_help.cpp +++ b/src/core/ms_help.cpp @@ -31,7 +31,8 @@ class CommandMSHelp : public Command { notice_help(Config.s_MemoServ, u, MEMO_HELP_HEADER); for (CommandMap::const_iterator it = MemoServ->Commands.begin(), it_end = MemoServ->Commands.end(); it != it_end; ++it) - it->second->OnServHelp(u); + if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission))) + it->second->OnServHelp(u); notice_help(Config.s_MemoServ, u, MEMO_HELP_FOOTER, Config.s_ChanServ); } }; diff --git a/src/core/ns_help.cpp b/src/core/ns_help.cpp index 423cc5c75..d23cbd208 100644 --- a/src/core/ns_help.cpp +++ b/src/core/ns_help.cpp @@ -42,7 +42,8 @@ class CommandNSHelp : public Command { notice_help(Config.s_NickServ, u, NICK_HELP); for (CommandMap::const_iterator it = NickServ->Commands.begin(), it_end = NickServ->Commands.end(); it != it_end; ++it) - it->second->OnServHelp(u); + if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission))) + it->second->OnServHelp(u); if (u->Account() && u->Account()->IsServicesOper()) notice_help(Config.s_NickServ, u, NICK_SERVADMIN_HELP); if (Config.NSExpire >= 86400) diff --git a/src/core/os_help.cpp b/src/core/os_help.cpp index 9ddeda66e..d88119bd2 100644 --- a/src/core/os_help.cpp +++ b/src/core/os_help.cpp @@ -30,7 +30,8 @@ class CommandOSHelp : public Command { notice_help(Config.s_OperServ, u, OPER_HELP); for (CommandMap::const_iterator it = OperServ->Commands.begin(), it_end = OperServ->Commands.end(); it != it_end; ++it) - it->second->OnServHelp(u); + if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission))) + it->second->OnServHelp(u); notice_help(Config.s_OperServ, u, OPER_HELP_LOGGED); } }; |