1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 12:46:39 +02:00

Adds check for opertype permissions to mod_run_cmd() in commands.c, and adds optional parameter to Command class constructor that takes the opertype permissions for the command.

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2292 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
cyberbotx
2009-05-05 22:26:41 +00:00
parent 845b15ddd9
commit dc102049b0
48 changed files with 62 additions and 146 deletions
+1 -1
View File
@@ -238,7 +238,7 @@ class CoreExport Command
* @param max_params The maximum number of parameters the parser will create, after max_params, all will be combined into the last argument.
* NOTE: If max_params is not set (default), there is no limit to the max number of params.
*/
Command(const std::string &sname, size_t min_params, size_t max_params = 0);
Command(const std::string &sname, size_t min_params, size_t max_params = 0, const std::string &spermission = "");
virtual ~Command();
+1 -1
View File
@@ -11,7 +11,7 @@
#include "services.h"
#include "modules.h"
Command::Command(const std::string &sname, size_t min_params, size_t max_params) : MaxParams(max_params), MinParams(min_params), name(sname)
Command::Command(const std::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission)
{
this->flags = 0;
this->help_param1 = NULL;
+11
View File
@@ -88,6 +88,17 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
// Check whether or not access string is empty
}
if (!c->permission.empty())
{
if (!u->nc->HasPriv(c->permission) && !u->nc->HasCommand(c->permission))
{
notice_lang(service, u, ACCESS_DENIED);
alog("Access denied for user %s with service %s and command %s", u->nick, service, cmd);
return;
}
}
std::vector<std::string> params;
std::string curparam;
char *s = NULL;
+1 -7
View File
@@ -18,7 +18,7 @@
class CommandCSForbid : public Command
{
public:
CommandCSForbid() : Command("FORBID", 1, 2)
CommandCSForbid() : Command("FORBID", 1, 2, "chanserv/forbid")
{
}
@@ -31,12 +31,6 @@ class CommandCSForbid : public Command
Channel *c;
if (!u->nc->HasCommand("chanserv/forbid"))
{
notice_lang(s_ChanServ, u, ACCESS_DENIED);
return MOD_CONT;
}
if (ForceForbidReason && !reason)
{
syntax_error(s_ChanServ, u, "FORBID", CHAN_FORBID_SYNTAX_REASON);
+1 -7
View File
@@ -18,7 +18,7 @@
class CommandCSGetPass : public Command
{
public:
CommandCSGetPass() : Command("GETPASS", 1, 1)
CommandCSGetPass() : Command("GETPASS", 1, 1, "chanserv/getpass")
{
this->SetFlag(CFLAG_ALLOW_SUSPENDED);
}
@@ -29,12 +29,6 @@ class CommandCSGetPass : public Command
char tmp_pass[PASSMAX];
ChannelInfo *ci;
if (!u->nc->HasCommand("chanserv/getpass"))
{
notice_lang(s_ChanServ, u, ACCESS_DENIED);
return MOD_CONT;
}
if (!(ci = cs_findchan(chan)))
{
notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+1 -4
View File
@@ -18,7 +18,7 @@
class CommandCSStatus : public Command
{
public:
CommandCSStatus() : Command("STATUS", 2, 2)
CommandCSStatus() : Command("STATUS", 2, 2, "chanserv/status")
{
}
@@ -30,9 +30,6 @@ class CommandCSStatus : public Command
const char *nick = params[1].c_str();
const char *temp = NULL;
if (!u->nc->HasCommand("chanserv/status"))
return MOD_CONT; // XXX: error?
if (!(ci = cs_findchan(chan)))
{
temp = chan;
+2 -8
View File
@@ -18,7 +18,7 @@
class CommandCSSuspend : public Command
{
public:
CommandCSSuspend() : Command("SUSPEND", 1, 2)
CommandCSSuspend() : Command("SUSPEND", 1, 2, "chanserv/suspend")
{
}
@@ -30,12 +30,6 @@ class CommandCSSuspend : public Command
Channel *c;
if (!u->nc->HasCommand("chanserv/suspend"))
{
notice_lang(s_ChanServ, u, ACCESS_DENIED);
return MOD_CONT; // XXX: error?
}
/* Assumes that permission checking has already been done. */
if (ForceForbidReason && !reason)
{
@@ -123,7 +117,7 @@ class CommandCSSuspend : public Command
class CommandCSUnSuspend : public Command
{
public:
CommandCSUnSuspend() : Command("UNSUSPEND", 1, 1)
CommandCSUnSuspend() : Command("UNSUSPEND", 1, 1, "chanserv/suspend")
{
this->SetFlag(CFLAG_ALLOW_SUSPENDED);
}
+1 -7
View File
@@ -18,18 +18,12 @@
class CommandHSDel : public Command
{
public:
CommandHSDel() : Command("DEL", 1, 1)
CommandHSDel() : Command("DEL", 1, 1, "hostserv/set")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasPriv("hostserv/set"))
{
notice_lang(s_HostServ, u, ACCESS_DENIED);
return MOD_CONT;
}
NickAlias *na;
const char *nick = params[0].c_str();
if ((na = findnick(nick)))
+1 -7
View File
@@ -18,18 +18,12 @@
class CommandHSDelAll : public Command
{
public:
CommandHSDelAll() : Command("DELALL", 1, 1)
CommandHSDelAll() : Command("DELALL", 1, 1, "hostserv/set")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasPriv("hostserv/set"))
{
notice_lang(s_HostServ, u, ACCESS_DENIED);
return MOD_CONT;
}
int i;
const char *nick = params[0].c_str();
NickAlias *na;
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandHSList : public Command
{
public:
CommandHSList() : Command("LIST", 0, 1)
CommandHSList() : Command("LIST", 0, 1, "hostserv/list")
{
}
+1 -7
View File
@@ -18,18 +18,12 @@
class CommandHSSet : public Command
{
public:
CommandHSSet() : Command("SET", 2, 2)
CommandHSSet() : Command("SET", 2, 2, "hostserv/set")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasPriv("hostserv/set"))
{
notice_lang(s_HostServ, u, ACCESS_DENIED);
return MOD_CONT;
}
const char *nick = params[0].c_str();
const char *rawhostmask = params[1].c_str();
char *hostmask = new char[HOSTMAX];
+1 -7
View File
@@ -20,18 +20,12 @@ extern int do_hs_sync(NickCore *nc, char *vIdent, char *hostmask, char *creator,
class CommandHSSetAll : public Command
{
public:
CommandHSSetAll() : Command("SETALL", 2, 2)
CommandHSSetAll() : Command("SETALL", 2, 2, "hostserv/set")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasPriv("hostserv/set"))
{
notice_lang(s_HostServ, u, ACCESS_DENIED);
return MOD_CONT;
}
const char *nick = params[0].c_str();
const char *rawhostmask = params[1].c_str();
char *hostmask = new char[HOSTMAX];
+1 -7
View File
@@ -18,7 +18,7 @@
class CommandMSSendAll : public Command
{
public:
CommandMSSendAll() : Command("SENDALL", 1, 1)
CommandMSSendAll() : Command("SENDALL", 1, 1, "memoserv/sendall")
{
}
@@ -28,12 +28,6 @@ class CommandMSSendAll : public Command
NickCore *nc;
const char *text = params[0].c_str();
if (!u->nc->HasCommand("memoserv/sendall"))
{
// XXX: error?
return MOD_CONT;
}
if (readonly)
{
notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
+1 -7
View File
@@ -18,7 +18,7 @@
class CommandMSStaff : public Command
{
public:
CommandMSStaff() : Command("STAFF", 1, 1)
CommandMSStaff() : Command("STAFF", 1, 1, "memoserv/staff")
{
}
@@ -28,12 +28,6 @@ class CommandMSStaff : public Command
int i, z = 0;
const char *text = params[0].c_str();
if (!u->nc->HasCommand("memoserv/staff"))
{
// XXX: error?
return MOD_CONT;
}
if (readonly)
{
notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
+1 -1
View File
@@ -20,7 +20,7 @@ NickAlias *makenick(const char *nick);
class CommandNSForbid : public Command
{
public:
CommandNSForbid() : Command("FORBID", 1, 2)
CommandNSForbid() : Command("FORBID", 1, 2, "nickserv/forbid")
{
}
+1 -1
View File
@@ -23,7 +23,7 @@
class CommandNSGetEMail : public Command
{
public:
CommandNSGetEMail() : Command("GETEMAIL", 1, 1)
CommandNSGetEMail() : Command("GETEMAIL", 1, 1, "nickserv/getemail")
{
}
+1 -7
View File
@@ -18,7 +18,7 @@
class CommandNSGetPass : public Command
{
public:
CommandNSGetPass() : Command("GETPASS", 1, 1)
CommandNSGetPass() : Command("GETPASS", 1, 1, "nickserv/getpass")
{
}
@@ -29,12 +29,6 @@ class CommandNSGetPass : public Command
NickAlias *na;
NickRequest *nr = NULL;
if (!u->nc->HasCommand("nickserv/getpass"))
{
notice_lang(s_NickServ, u, ACCESS_DENIED);
return MOD_CONT;
}
if (!(na = findnick(nick)))
{
if ((nr = findrequestnick(nick)))
+1 -1
View File
@@ -473,7 +473,7 @@ private:
return MOD_CONT;
}
public:
CommandNSSASet() : Command("SASET", 2, 4)
CommandNSSASet() : Command("SASET", 2, 4, "nickserv/saset")
{
}
+2 -2
View File
@@ -18,7 +18,7 @@
class CommandNSSuspend : public Command
{
public:
CommandNSSuspend() : Command("SUSPEND", 2, 2)
CommandNSSuspend() : Command("SUSPEND", 2, 2, "nickserv/suspend")
{
}
@@ -105,7 +105,7 @@ class CommandNSSuspend : public Command
class CommandNSUnSuspend : public Command
{
public:
CommandNSUnSuspend() : Command("UNSUSPEND", 1, 1)
CommandNSUnSuspend() : Command("UNSUSPEND", 1, 1, "nickserv/suspend")
{
}
+1 -13
View File
@@ -33,12 +33,6 @@ class CommandOSAdmin : public Command
return MOD_CONT;
}
if (!u->nc->HasCommand("operserv/admin"))
{
notice_lang(s_OperServ, u, ACCESS_DENIED);
return MOD_CONT;
}
if (!(na = findnick(nick)))
{
notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
@@ -200,7 +194,7 @@ class CommandOSAdmin : public Command
return MOD_CONT;
}
public:
CommandOSAdmin() : Command("ADMIN", 1, 2)
CommandOSAdmin() : Command("ADMIN", 1, 2, "operserv/admin")
{
}
@@ -208,12 +202,6 @@ class CommandOSAdmin : public Command
{
const char *cmd = params[0].c_str();
if (!u->nc->HasCommand("operserv/admin"))
{
notice_lang(s_OperServ, u, ACCESS_DENIED);
return MOD_CONT;
}
if (!stricmp(cmd, "ADD"))
return this->DoAdd(u, params);
else if (!stricmp(cmd, "DEL"))
+1 -1
View File
@@ -286,7 +286,7 @@ class CommandOSAKill : public Command
return MOD_CONT;
}
public:
CommandOSAKill() : Command("AKILL", 1, 4)
CommandOSAKill() : Command("AKILL", 1, 4, "operserv/akill")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSChanKill : public Command
{
public:
CommandOSChanKill() : Command("CHANKILL", 2, 3)
CommandOSChanKill() : Command("CHANKILL", 2, 3, "operserv/chankill")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSClearModes : public Command
{
public:
CommandOSClearModes() : Command("CLEARMODES", 1, 2)
CommandOSClearModes() : Command("CLEARMODES", 1, 2, "operserv/clearmodes")
{
}
+1 -1
View File
@@ -20,7 +20,7 @@ void defcon_sendlvls(User *u);
class CommandOSDEFCON : public Command
{
public:
CommandOSDEFCON() : Command("DEFCON", 1, 1)
CommandOSDEFCON() : Command("DEFCON", 1, 1, "operserv/defcon")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSGlobal : public Command
{
public:
CommandOSGlobal() : Command("GLOBAL", 1, 1)
CommandOSGlobal() : Command("GLOBAL", 1, 1, "operserv/global")
{
}
+1 -1
View File
@@ -96,7 +96,7 @@ class CommandOSIgnore : public Command
return MOD_CONT;
}
public:
CommandOSIgnore() : Command("IGNORE", 1, 3)
CommandOSIgnore() : Command("IGNORE", 1, 3, "operserv/ignore")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSJupe : public Command
{
public:
CommandOSJupe() : Command("JUPE", 1, 2)
CommandOSJupe() : Command("JUPE", 1, 2, "operserv/jupe")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSKick : public Command
{
public:
CommandOSKick() : Command("KICK", 3, 3)
CommandOSKick() : Command("KICK", 3, 3, "operserv/kick")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSMode : public Command
{
public:
CommandOSMode() : Command("MODE", 2, 2)
CommandOSMode() : Command("MODE", 2, 2, "operserv/mode")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSModList : public Command
{
public:
CommandOSModList() : Command("MODLIST", 0, 1)
CommandOSModList() : Command("MODLIST", 0, 1, "operserv/modlist")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSModLoad : public Command
{
public:
CommandOSModLoad() : Command("MODLOAD", 1, 1)
CommandOSModLoad() : Command("MODLOAD", 1, 1, "operserv/modload")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSModUnLoad : public Command
{
public:
CommandOSModUnLoad() : Command("MODUNLOAD", 1, 1)
CommandOSModUnLoad() : Command("MODUNLOAD", 1, 1, "operserv/modload")
{
}
+2 -1
View File
@@ -225,7 +225,7 @@ class NewsBase : public Command
return MOD_CONT;
}
public:
NewsBase(const std::string &newstype) : Command(newstype, 1, 2)
NewsBase(const std::string &newstype) : Command(newstype, 1, 2, "operserv/news")
{
}
@@ -366,6 +366,7 @@ class OSNews : public Module
this->AddCommand(OPERSERV, new CommandOSRandomNews(), MOD_UNIQUE);
ModuleManager::Attach(I_OnReload, this);
}
void OperServHelp(User *u)
{
notice_lang(s_OperServ, u, OPER_HELP_CMD_LOGONNEWS);
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSNOOP : public Command
{
public:
CommandOSNOOP() : Command("NOOP", 2, 2)
CommandOSNOOP() : Command("NOOP", 2, 2, "operserv/noop")
{
}
+1 -7
View File
@@ -196,7 +196,7 @@ class CommandOSOper : public Command
return MOD_CONT;
}
public:
CommandOSOper() : Command("OPER", 1, 2)
CommandOSOper() : Command("OPER", 1, 2, "operserv/oper")
{
}
@@ -204,12 +204,6 @@ class CommandOSOper : public Command
{
const char *cmd = params[0].c_str();
if (!u->nc->HasCommand("operserv/oper"))
{
notice_lang(s_OperServ, u, ACCESS_DENIED);
return MOD_CONT;
}
if (!stricmp(cmd, "ADD"))
return this->DoAdd(u, params);
else if (!stricmp(cmd, "DEL"))
+1 -5
View File
@@ -18,16 +18,12 @@
class CommandOSQuit : public Command
{
public:
CommandOSQuit() : Command("QUIT", 0, 0)
CommandOSQuit() : Command("QUIT", 0, 0, "operserv/quit")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasCommand("operserv/quit")) {
notice_lang(s_OperServ, u, ACCESS_DENIED);
return MOD_STOP;
}
quitmsg = new char[28 + strlen(u->nick)];
if (!quitmsg)
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSReload : public Command
{
public:
CommandOSReload() : Command("RELOAD", 0, 0)
CommandOSReload() : Command("RELOAD", 0, 0, "operserv/reload")
{
}
+1 -8
View File
@@ -18,16 +18,12 @@
class CommandOSRestart : public Command
{
public:
CommandOSRestart() : Command("RESTART", 0, 0)
CommandOSRestart() : Command("RESTART", 0, 0, "operserv/restart")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasCommand("operserv/restart")) {
notice_lang(s_OperServ, u, ACCESS_DENIED);
return MOD_STOP;
}
#ifdef SERVICES_BIN
quitmsg = new char[31 + strlen(u->nick)];
@@ -48,9 +44,6 @@ class CommandOSRestart : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
if (!u->nc->HasCommand("operserv/restart"))
return false;
notice_help(s_OperServ, u, OPER_HELP_RESTART);
return true;
}
+1 -1
View File
@@ -58,7 +58,7 @@ class CommandOSSession : public Command
return MOD_CONT;
}
public:
CommandOSSession() : Command("SESSION", 2, 2)
CommandOSSession() : Command("SESSION", 2, 2, "operserv/session")
{
}
+1 -1
View File
@@ -233,7 +233,7 @@ class CommandOSSet : public Command
return MOD_CONT;
}
public:
CommandOSSet() : Command("SET", 1, 2)
CommandOSSet() : Command("SET", 1, 2, "operserv/set")
{
}
+1 -1
View File
@@ -283,7 +283,7 @@ class CommandOSSGLine : public Command
return MOD_CONT;
}
public:
CommandOSSGLine() : Command("SGLINE", 1, 3)
CommandOSSGLine() : Command("SGLINE", 1, 3, "operserv/sgline")
{
}
+1 -5
View File
@@ -18,16 +18,12 @@
class CommandOSShutdown : public Command
{
public:
CommandOSShutdown() : Command("SHUTDOWN", 0, 0)
CommandOSShutdown() : Command("SHUTDOWN", 0, 0, "operserv/shutdown")
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
if (!u->nc->HasCommand("operserv/shutdown")) {
notice_lang(s_OperServ, u, ACCESS_DENIED);
return MOD_STOP;
}
quitmsg = new char[32 + strlen(u->nick)];
if (!quitmsg)
+1 -1
View File
@@ -270,7 +270,7 @@ class CommandOSSQLine : public Command
return MOD_CONT;
}
public:
CommandOSSQLine() : Command("SQLINE", 1, 4)
CommandOSSQLine() : Command("SQLINE", 1, 4, "operserv/sqline")
{
}
+1 -1
View File
@@ -21,7 +21,7 @@ int opers_list(int number, NickCore *nc, User *u, char *level);
class CommandOSStaff : public Command
{
public:
CommandOSStaff() : Command("STAFF", 0, 0)
CommandOSStaff() : Command("STAFF", 0, 0, "operserv/staff")
{
}
+1 -1
View File
@@ -275,7 +275,7 @@ class CommandOSStats : public Command
return MOD_CONT;
}
public:
CommandOSStats() : Command("STATS", 0, 1)
CommandOSStats() : Command("STATS", 0, 1, "operserv/stats")
{
}
+1 -1
View File
@@ -269,7 +269,7 @@ class CommandOSSZLine : public Command
return MOD_CONT;
}
public:
CommandOSSZLine() : Command("SZLINE", 1, 4)
CommandOSSZLine() : Command("SZLINE", 1, 4, "operserv/szline")
{
}
+1 -1
View File
@@ -18,7 +18,7 @@
class CommandOSUpdate : public Command
{
public:
CommandOSUpdate() : Command("UPDATE", 0, 0)
CommandOSUpdate() : Command("UPDATE", 0, 0, "operserv/update")
{
}
+2 -2
View File
@@ -106,7 +106,7 @@ class CommandNSOInfo : public Command
return MOD_CONT;
}
public:
CommandNSOInfo() : Command("OINFO", 2, 3)
CommandNSOInfo() : Command("OINFO", 2, 3, "nickserv/oinfo")
{
}
@@ -193,7 +193,7 @@ class CommandCSOInfo : public Command
return MOD_CONT;
}
public:
CommandCSOInfo() : Command("OINFO", 2, 3)
CommandCSOInfo() : Command("OINFO", 2, 3, "chanserv/oinfo")
{
}