1
0
mirror of https://github.com/anope/anope.git synced 2026-06-30 22:06:38 +02:00

Made opertypes inheritable

This commit is contained in:
Adam
2010-05-07 15:29:41 -04:00
committed by Adam
parent 9439cac6b1
commit ebfff71599
6 changed files with 113 additions and 36 deletions
+50 -29
View File
@@ -611,29 +611,49 @@ options
* Below are some default example types, but this is by no means exhaustive,
* and it is recommended that you configure them to your liking.
*/
opertype
{
// The name of this opertype
name = "Services Root"
/* The name of this opertype */
name = "Helper"
// What commands (see above) this opertype may use
commands = "*"
/* What privs (see above) this opertype has */
privs = "hostserv/set"
}
// What privs (see above) this opertype has
privs = "*"
opertype
{
/* The name of this opertype */
name = "Services Operator"
/* What opertype(s) this inherits from. Seperate with a comma. */
inherits = "Helper, Another Helper"
/* What commands (see above) this opertype may use */
commands = "chanserv/list chanserv/suspend chanserv/status chanserv/topic memoserv/staff nickserv/sendpass nickserv/resetpass nickserv/suspend operserv/mode operserv/chankill operserv/szline operserv/akill operserv/session operserv/clearmodes operserv/modlist operserv/sqline operser/staff operserv/kick operserv/ignore operserv/sgline"
/* What privs (see above) this opertype has */
privs = "chanserv/auspex chanserv/no-register-limit memoserv/* nickserv/auxpex nickserv/confirm"
}
opertype
{
name = "Services Administrator"
commands = "operserv/global operserv/news operserv/stats operserv/kick operserv/mode operserv/session operserv/modlist operserv/ignore operserv/chankill operserv/akill operserv/sqline operserv/sgline operserv/szline operserv/clearmodes operserv/staff operserv/defcon botserv/* chanserv/* nickserv/* memoserv/*"
inherits = "Services Operator"
commands = "chanserv/access/list chanserv/drop chanserv/forbid chansev/getkey chanserv/getkey chanserv/set/noexpire memoserv/sendall nickserv/getemail operserv/global operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/defcon operserv/noop operserv/umode"
privs = "*"
}
opertype
{
name = "Helper"
privs = "hostserv/set"
name = "Services Root"
commands = "*"
privs = "*"
}
/*
@@ -645,26 +665,27 @@ opertype
*
* As with all permissions, make sure to only give trustworthy people access to Services.
*/
#oper
#{
# // The nickname of this services oper
# name = "DukePyrolator"
#
# // The opertype this person will have
# type = "Services Root"
#}#
#
#oper
#{
# name = "nick1"
# type = "Services Administrator"
#}#
#
#oper
#{
# name = "nick2"
# type = "Helper"
#}
oper
{
/* The nickname of this services oper */
//name = "nick1"
/* The opertype this person will have */
type = "Services Root"
}
oper
{
//name = "nick2"
type = "Services Administrator"
}
oper
{
//name = "nick3"
type = "Helper"
}
/*
* [OPTIONAL] Mail Config
+4
View File
@@ -1,6 +1,10 @@
Anope Version 1.9.3
--------------------
A Tell users when their nicks expire in /ns glist and /ns info
A Added SSL support
A Added official support for InspIRCd 2.0
A Prevent negaitve mode changes, kicks, bans, and autokicks from affecting people with the 'god' user mode (On UnrealIRCd, usermode +q)
A Added nickserv/auxpex permission
Anope Version 1.9.2
--------------------
+2
View File
@@ -2,6 +2,8 @@ Anope Version 1.9.3
------------------
** ADDED CONFIGURATION DIRECTIVES **
nickserv/auspex privilege added
SSL module added for SSL support
opertype:inherits added to allow opertypes to inherit commands and privs from other opertypes
** MODIFIED CONFIGURATION DIRECTIVES **
+9
View File
@@ -31,6 +31,10 @@ class CoreExport OperType
* as we don't invoke it often.
*/
std::list<std::string> commands;
/** Set of opertypes we inherit from
*/
std::set<OperType *> inheritances;
public:
/** Create a new opertype of the given name.
* @param nname The opertype name, e.g. "sra".
@@ -62,4 +66,9 @@ class CoreExport OperType
/** Returns the name of this opertype.
*/
const ci::string &GetName() const;
/** Make this opertype inherit commands and privs from another opertype
* @param ot The opertype to inherit from
*/
void Inherits(OperType *ot);
};
+23 -5
View File
@@ -425,8 +425,9 @@ static bool InitOperTypes(ServerConfig *, const char *, bool)
static bool DoOperType(ServerConfig *conf, const char *, const char **, ValueList &values, int *, bool)
{
const char *name = values[0].GetString();
const char *commands = values[1].GetString();
const char *privs = values[2].GetString();
const char *inherits = values[1].GetString();
const char *commands = values[2].GetString();
const char *privs = values[3].GetString();
ValueItem vi(name);
if (!ValidateNotEmpty(conf, "opertype", "name", vi))
@@ -442,6 +443,23 @@ static bool DoOperType(ServerConfig *conf, const char *, const char **, ValueLis
spacesepstream privstr(privs);
while (privstr.GetToken(tok))
ot->AddPriv(tok);
commasepstream inheritstr(inherits);
while (inheritstr.GetToken(tok))
{
/* Strip leading ' ' after , */
if (tok.size() > 1 && tok[0] == ' ')
tok.erase(tok.begin());
for (std::list<OperType *>::iterator it = Config.MyOperTypes.begin(); it != Config.MyOperTypes.end(); ++it)
{
if ((*it)->GetName() == tok)
{
Alog() << "Inheriting commands and privs from " << (*it)->GetName() << " to " << ot->GetName();
ot->Inherits(*it);
break;
}
}
}
Config.MyOperTypes.push_back(ot);
return true;
@@ -772,9 +790,9 @@ int ServerConfig::Read(bool bail)
{DT_CHARPTR},
InitModules, DoModule, DoneModules},
{"opertype",
{"name", "commands", "privs", NULL},
{"", "", "", NULL},
{DT_CHARPTR, DT_CHARPTR, DT_CHARPTR},
{"name", "inherits", "commands", "privs", NULL},
{"", "", "", "", NULL},
{DT_CHARPTR, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR},
InitOperTypes, DoOperType, DoneOperTypes},
{"oper",
{"name", "type", NULL},
+25 -2
View File
@@ -16,26 +16,44 @@ OperType::OperType(const ci::string &nname) : name(nname)
bool OperType::HasCommand(const std::string &cmdstr) const
{
for (std::list<std::string>::const_iterator it = this->commands.begin(); it != this->commands.end(); it++)
for (std::list<std::string>::const_iterator it = this->commands.begin(); it != this->commands.end(); ++it)
{
if (Anope::Match(cmdstr, *it))
{
return true;
}
}
for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(); iit != this->inheritances.end(); ++iit)
{
OperType *ot = *iit;
if (ot->HasCommand(cmdstr))
{
return true;
}
}
return false;
}
bool OperType::HasPriv(const std::string &privstr) const
{
for (std::list<std::string>::const_iterator it = this->privs.begin(); it != this->privs.end(); it++)
for (std::list<std::string>::const_iterator it = this->privs.begin(); it != this->privs.end(); ++it)
{
if (Anope::Match(privstr, *it))
{
return true;
}
}
for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(); iit != this->inheritances.end(); ++iit)
{
OperType *ot = *iit;
if (ot->HasPriv(privstr))
{
return true;
}
}
return false;
}
@@ -55,3 +73,8 @@ const ci::string &OperType::GetName() const
return this->name;
}
void OperType::Inherits(OperType *ot)
{
this->inheritances.insert(ot);
}