From 64a926656777aaaefaf355c4ee6d40ccd479039d Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Dec 2005 02:14:36 +0000 Subject: [PATCH] Added permissions checks, ick! git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2102 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index c2b5ebf9b..e20a374be 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1630,8 +1630,19 @@ bool is_valid_cmd(const char* commandname, int pcnt, userrec * user) { if ((pcnt>=cmdlist[i].min_params) && (strcasecmp(cmdlist[i].source,""))) { - if (strchr(user->modes,cmdlist[i].flags_needed)) + if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed)) { + if (cmdlist[i].flags_needed) + { + if (!user->HasPermission(command)) + { + return true; + } + else + { + return false; + } + } return true; } } @@ -1645,15 +1656,24 @@ bool is_valid_cmd(const char* commandname, int pcnt, userrec * user) void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user) { - for (unsigned int i = 0; i < cmdlist.size(); i++) + for (unsigned int i = 0; i < cmdlist.size(); i++) + { + if (!strcasecmp(cmdlist[i].command,commandname)) { - if (!strcasecmp(cmdlist[i].command,commandname)) + if (cmdlist[i].handler_function) { - if (cmdlist[i].handler_function) + if (pcnt>=cmdlist[i].min_params) { - if (pcnt>=cmdlist[i].min_params) + if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed)) { - if (strchr(user->modes,cmdlist[i].flags_needed)) + if (cmdlist[i].flags_needed) + { + if (!user->HasPermission(command)) + { + cmdlist[i].handler_function(parameters,pcnt,user); + } + } + else { cmdlist[i].handler_function(parameters,pcnt,user); } @@ -1661,6 +1681,7 @@ void call_handler(const char* commandname,char **parameters, int pcnt, userrec * } } } + } } -- 2.39.2