summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/access.cpp43
-rw-r--r--src/config.cpp34
-rw-r--r--src/init.cpp1
3 files changed, 38 insertions, 40 deletions
diff --git a/src/access.cpp b/src/access.cpp
index 09310d441..8a293a42d 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -56,49 +56,14 @@ Privilege *PrivilegeManager::FindPrivilege(const Anope::string &name)
return NULL;
}
-void PrivilegeManager::Init()
+std::vector<Privilege> &PrivilegeManager::GetPrivileges()
{
- AddPrivilege(Privilege("ACCESS_LIST", _("Allowed to view the access list")));
- AddPrivilege(Privilege("NOKICK", _("Prevents users being kicked by Services")));
- AddPrivilege(Privilege("FANTASIA", _("Allowed to use fantasy commands")));
- AddPrivilege(Privilege("FOUNDER", _("Allowed to issue commands restricted to channel founders")));
- AddPrivilege(Privilege("GREET", _("Greet message displayed")));
- AddPrivilege(Privilege("AUTOVOICE", _("Automatic mode +v")));
- AddPrivilege(Privilege("VOICEME", _("Allowed to (de)voice him/herself")));
- AddPrivilege(Privilege("VOICE", _("Allowed to (de)voice users")));
- AddPrivilege(Privilege("INFO", _("Allowed to use INFO command with ALL option")));
- AddPrivilege(Privilege("SAY", _("Allowed to use SAY and ACT commands")));
- AddPrivilege(Privilege("AUTOHALFOP", _("Automatic mode +h")));
- AddPrivilege(Privilege("HALFOPME", _("Allowed to (de)halfop him/herself")));
- AddPrivilege(Privilege("HALFOP", _("Allowed to (de)halfop users")));
- AddPrivilege(Privilege("KICK", _("Allowed to use the KICK command")));
- AddPrivilege(Privilege("SIGNKICK", _("No signed kick when SIGNKICK LEVEL is used")));
- AddPrivilege(Privilege("BAN", _("Allowed to use ban users")));
- AddPrivilege(Privilege("TOPIC", _("Allowed to change channel topics")));
- AddPrivilege(Privilege("MODE", _("Allowed to change channel modes")));
- AddPrivilege(Privilege("GETKEY", _("Allowed to use GETKEY command")));
- AddPrivilege(Privilege("INVITE", _("Allowed to use the INVITE command")));
- AddPrivilege(Privilege("UNBAN", _("Allowed to unban users")));
- AddPrivilege(Privilege("AUTOOP", _("Automatic channel operator status")));
- AddPrivilege(Privilege("AUTOOWNER", _("Automatic mode +q")));
- AddPrivilege(Privilege("OPDEOPME", _("Allowed to (de)op him/herself")));
- AddPrivilege(Privilege("OPDEOP", _("Allowed to (de)op users")));
- AddPrivilege(Privilege("AUTOPROTECT", _("Automatic mode +a")));
- AddPrivilege(Privilege("AKICK", _("Allowed to use AKICK command")));
- AddPrivilege(Privilege("BADWORDS", _("Allowed to modify channel badwords list")));
- AddPrivilege(Privilege("ASSIGN", _("Allowed to assign/unassign a bot")));
- AddPrivilege(Privilege("MEMO", _("Allowed to read channel memos")));
- AddPrivilege(Privilege("ACCESS_CHANGE", _("Allowed to modify the access list")));
- AddPrivilege(Privilege("PROTECT", _("Allowed to (de)protect users")));
- AddPrivilege(Privilege("PROTECTME", _("Allowed to (de)protect him/herself")));
- AddPrivilege(Privilege("SET", _("Allowed to set channel settings")));
- AddPrivilege(Privilege("OWNERME", _("Allowed to (de)owner him/herself")));
- AddPrivilege(Privilege("OWNER", _("Allowed to (de)owner users")));
+ return privs;
}
-std::vector<Privilege> &PrivilegeManager::GetPrivileges()
+void PrivilegeManager::ClearPrivileges()
{
- return privs;
+ privs.clear();
}
AccessProvider::AccessProvider(Module *o, const Anope::string &n) : Service<AccessProvider>(o, n)
diff --git a/src/config.cpp b/src/config.cpp
index 28a0b6a9c..5cb067735 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -872,6 +872,35 @@ static bool DoneCommands(ServerConfig *config, const Anope::string &)
return true;
}
+static bool InitPrivileges(ServerConfig *config, const Anope::string &)
+{
+ PrivilegeManager::ClearPrivileges();
+ return true;
+}
+
+static bool DoPrivileges(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *)
+{
+ Anope::string name = values[0].GetValue();
+ Anope::string desc = values[1].GetValue();
+
+ ValueItem vi(name);
+ if (!ValidateNotEmpty(config, "privilege", "name", vi))
+ throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
+
+ vi = ValueItem(desc);
+ if (!ValidateNotEmpty(config, "privilege", "desc", vi))
+ throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
+
+ PrivilegeManager::AddPrivilege(Privilege(name, desc));
+ return true;
+}
+
+static bool DonePrivileges(ServerConfig *config, const Anope::string &)
+{
+ Log(LOG_DEBUG) << "Loaded " << PrivilegeManager::GetPrivileges().size() << " privileges";
+ return true;
+}
+
/*************************************************************************/
static std::set<Anope::string> services;
@@ -1283,6 +1312,11 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"", "", "", "", ""},
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
InitCommands, DoCommands, DoneCommands},
+ {"privilege",
+ {"name", "desc", ""},
+ {"", "", ""},
+ {DT_STRING, DT_STRING, DT_STRING},
+ InitPrivileges, DoPrivileges, DonePrivileges},
{"",
{""},
{""},
diff --git a/src/init.cpp b/src/init.cpp
index 76ba350bb..4cff3fc91 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -355,7 +355,6 @@ void Init(int ac, char **av)
/* Initialize the socket engine */
SocketEngine::Init();
- PrivilegeManager::Init();
/* Create me */
Me = new Server(NULL, Config->ServerName, 0, Config->ServerDesc, Config->Numeric);