diff options
-rw-r--r-- | include/command_parse.h | 2 | ||||
-rw-r--r-- | include/modules.h | 3 | ||||
-rw-r--r-- | src/command_parse.cpp | 12 | ||||
-rw-r--r-- | src/modules.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 6 |
5 files changed, 15 insertions, 12 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index a58dfe5d1..5709f5c6a 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -34,7 +34,7 @@ class CommandParser command_table cmdlist; CommandParser(); - void CallHandler(std::string &commandname,char **parameters, int pcnt, userrec *user); + bool CallHandler(std::string &commandname,char **parameters, int pcnt, userrec *user); bool IsValidCommand(std::string &commandname, int pcnt, userrec * user); int LoopCall(command_t *fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins); void ProcessBuffer(const char* cmdbuf,userrec *user); diff --git a/include/modules.h b/include/modules.h index 8eae4f6a3..4dff5d48a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1597,8 +1597,9 @@ class Server : public classbase * in the array. If you do not pass enough parameters to meet the minimum needed by the handler, the * functiom will silently ignore it. The final parameter is the user executing the command handler, * used for privilage checks, etc. + * @return True if the command exists */ - virtual void CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user); + virtual bool CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user); /** This function returns true if the commandname exists, pcnt is equal to or greater than the number * of paramters the command requires, the user specified is allowed to execute the command, AND diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 18915b819..77fef66d7 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -288,7 +288,7 @@ bool CommandParser::IsValidCommand(std::string &commandname, int pcnt, userrec * // calls a handler function for a command -void CommandParser::CallHandler(std::string &commandname,char **parameters, int pcnt, userrec *user) +bool CommandParser::CallHandler(std::string &commandname,char **parameters, int pcnt, userrec *user) { nspace::hash_map<std::string,command_t*>::iterator n = cmdlist.find(commandname); @@ -300,23 +300,21 @@ void CommandParser::CallHandler(std::string &commandname,char **parameters, int { if (n->second->flags_needed) { - if ((user->HasPermission(commandname)) || (is_uline(user->server))) + if ((user->HasPermission(commandname)) || (!IS_LOCAL(user))) { n->second->Handle(parameters,pcnt,user); - } - else - { - if (!IS_LOCAL(user)) - WriteOpers("*** \2WARNING\2: Command '%s' not allowed for oper '%s', dropped.",commandname.c_str(),user->nick); + return true; } } else { n->second->Handle(parameters,pcnt,user); + return true; } } } } + return false; } int CommandParser::ProcessParameters(char **command_p,char *parameters) diff --git a/src/modules.cpp b/src/modules.cpp index 9b6a0d826..64a61c1b0 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -486,9 +486,9 @@ bool Server::IsUlined(std::string server) return is_uline(server.c_str()); } -void Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user) +bool Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user) { - ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user); + return ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user); } bool Server::IsValidModuleCommand(std::string commandname, int pcnt, userrec* user) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index b33e28af8..f927ac044 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -2513,7 +2513,11 @@ class TreeSocket : public InspSocket { strparams[q] = (char*)params[q].c_str(); } - Srv->CallCommandHandler(command.c_str(), strparams, params.size(), who); + if (!Srv->CallCommandHandler(command.c_str(), strparams, params.size(), who)) + { + this->WriteLine("ERROR :Unrecognised command -- possibly loaded mismatched modules"); + return false; + } } else { |