diff options
-rw-r--r-- | include/inspircd_io.h | 5 | ||||
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | src/cmd_stats.cpp | 11 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 3 | ||||
-rw-r--r-- | src/modules.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 14 |
6 files changed, 26 insertions, 13 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h index 76398a6e2..d89f41828 100644 --- a/include/inspircd_io.h +++ b/include/inspircd_io.h @@ -269,6 +269,11 @@ class ServerConfig : public classbase */ std::string data005; + /** STATS characters in this list are available + * only to operators. + */ + char OperOnlyStats[MAXBUF]; + ServerConfig(); /** Clears the include stack in preperation for diff --git a/include/modules.h b/include/modules.h index 460cc6566..1530592d3 100644 --- a/include/modules.h +++ b/include/modules.h @@ -987,8 +987,10 @@ class Module : public classbase /** Called on all /STATS commands * This method is triggered for all /STATS use, including stats symbols handled by the core. * @param symbol the symbol provided to /STATS + * @user the user issuing the /STATS command + * @return 1 to block the /STATS from being processed by the core, 0 to allow it */ - virtual void OnStats(char symbol); + virtual int OnStats(char symbol, userrec* user); /** Called whenever a change of a local users displayed host is attempted. * Return 1 to deny the host change, or 0 to allow it. diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 2d45aa873..53c371816 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -84,8 +84,17 @@ void cmd_stats::Handle (char **parameters, int pcnt, userrec *user) parameters[0][1] = '\0'; } + if ((strchr(Config->OperOnlyStats,*parameters[0])) && (!*user->oper)) + { + WriteServ(user->fd,"481 %s :Permission denied - This stats character is set as oper-only"); + return; + } - FOREACH_MOD(I_OnStats,OnStats(*parameters[0])); + + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnStats,OnStats(*parameters[0],user)); + if (MOD_RESULT) + return; if (*parameters[0] == 'c') { diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index 42ae122e8..d685faf4e 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -43,7 +43,7 @@ ServerConfig::ServerConfig() *ServerName = *Network = *ServerDesc = *AdminName = '\0'; *AdminEmail = *AdminNick = *diepass = *restartpass = '\0'; *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0'; - *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0'; + *OperOnlyStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0'; log_file = NULL; nofork = false; unlimitcore = false; @@ -157,6 +157,7 @@ void ServerConfig::Read(bool bail, userrec* user) ConfValue("disabled","commands",0,Config->DisabledCommands,&Config->config_f); ConfValue("options","somaxconn",0,MCON,&Config->config_f); ConfValue("options","softlimit",0,SLIMT,&Config->config_f); + ConfValue("options","operonlystats",0,Config->OperOnlyStats,&Config->config_f); Config->SoftLimit = atoi(SLIMT); if ((Config->SoftLimit < 1) || (Config->SoftLimit > MAXCLIENTS)) diff --git a/src/modules.cpp b/src/modules.cpp index b3b2daab3..8f328e205 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -255,7 +255,7 @@ int Module::OnCheckInvite(userrec* user, chanrec* chan) { return 0; }; int Module::OnCheckKey(userrec* user, chanrec* chan, std::string keygiven) { return 0; }; int Module::OnCheckLimit(userrec* user, chanrec* chan) { return 0; }; int Module::OnCheckBan(userrec* user, chanrec* chan) { return 0; }; -void Module::OnStats(char symbol) { }; +int Module::OnStats(char symbol, userrec* user) { }; int Module::OnChangeLocalUserHost(userrec* user, std::string newhost) { return 0; }; int Module::OnChangeLocalUserGECOS(userrec* user, std::string newhost) { return 0; }; int Module::OnLocalTopicChange(userrec* user, chanrec* chan, std::string topic) { return 0; }; diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 1e597c910..369bda8ef 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -2715,9 +2715,9 @@ class ModuleSpanningTree : public Module return 1; } - virtual bool HandleStats(char ** parameters, int pcnt, userrec* user) + virtual int OnStats(char statschar, userrec* user) { - if (*parameters[0] == 'c') + if (statschar == 'c') { for (unsigned int i = 0; i < LinkBlocks.size(); i++) { @@ -2726,9 +2726,9 @@ class ModuleSpanningTree : public Module } WriteServ(user->fd,"219 %s %s :End of /STATS report",user->nick,parameters[0]); WriteOpers("*** Notice: Stats '%s' requested by %s (%s@%s)",parameters[0],user->nick,user->ident,user->host); - return true; + return 1; } - return false; + return 0; } virtual int OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user, bool validated) @@ -2745,10 +2745,6 @@ class ModuleSpanningTree : public Module { return this->HandleSquit(parameters,pcnt,user); } - else if (command == "STATS") - { - return this->HandleStats(parameters,pcnt,user); - } else if (command == "MAP") { this->HandleMap(parameters,pcnt,user); @@ -3219,7 +3215,7 @@ class ModuleSpanningTree : public Module List[I_OnUserQuit] = List[I_OnUserPostNick] = List[I_OnUserKick] = List[I_OnRemoteKill] = List[I_OnRehash] = 1; List[I_OnOper] = List[I_OnAddGLine] = List[I_OnAddZLine] = List[I_OnAddQLine] = List[I_OnAddELine] = 1; List[I_OnDelGLine] = List[I_OnDelZLine] = List[I_OnDelQLine] = List[I_OnDelELine] = List[I_ProtoSendMode] = List[I_OnMode] = 1; - List[I_ProtoSendMetaData] = 1; + List[I_OnStats] = List[I_ProtoSendMetaData] = 1; } }; |