summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--include/modules.h16
-rw-r--r--src/core/os_modunload.c1
-rw-r--r--src/module.cpp12
-rw-r--r--src/modulemanager.cpp4
5 files changed, 32 insertions, 3 deletions
diff --git a/TODO b/TODO
index 0bbfe040d..0e1173f0e 100644
--- a/TODO
+++ b/TODO
@@ -13,7 +13,7 @@ Legend:
[x] Change MODULE_INIT to return a pointer
[x] Remove duplicate module creation.. have loadModule return a pointer rather than creating one
[x] Remove buffered loading/unloading, this makes os_modunload perm, but who cares
- [ ] Mark os_modunload permanent.
+ [x] Mark os_modunload permanent.
[x] Remove 'delayed' loading, this is necessary because of before/after connected to ircd (ircd is before, rest after), I'm sure this can be done better.
[ ] Remove modules_unload_all fini + hack that goes with it
[+] Remove mod_current_* crap (involves passing Module * around a lot)
diff --git a/include/modules.h b/include/modules.h
index 28b3065d7..93e399819 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -136,6 +136,8 @@ struct ModuleLang_ {
*/
CoreExport class Module
{
+ private:
+ bool permanent;
public:
/** The module name (e.g. os_modload)
*/
@@ -177,6 +179,20 @@ CoreExport class Module
*/
void SetType(MODType type);
+ /** Toggles the permanent flag on a module. If a module is permanent,
+ * then it may not be unloaded.
+ *
+ * Naturally, this setting should be used sparingly!
+ *
+ * @param state True if this module should be permanent, false else.
+ */
+ void SetPermanent(bool state);
+
+ /** Retrieves whether or not a given module is permanent.
+ * @return true if the module is permanent, false else.
+ */
+ bool GetPermanent();
+
/** Set the modules version info.
* @param version the version of the module
*/
diff --git a/src/core/os_modunload.c b/src/core/os_modunload.c
index 8fde45fc8..96790357f 100644
--- a/src/core/os_modunload.c
+++ b/src/core/os_modunload.c
@@ -29,6 +29,7 @@ class OSModUnLoad : public Module
this->SetAuthor("Anope");
this->SetVersion("$Id$");
this->SetType(CORE);
+ this->SetPermanent(true);
c = createCommand("MODUNLOAD", do_modunload, is_services_root, -1, -1, -1, -1, OPER_HELP_MODUNLOAD);
this->AddCommand(OPERSERV, c, MOD_UNIQUE);
diff --git a/src/module.cpp b/src/module.cpp
index 08d1a1cf0..7179d8bdf 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -31,6 +31,8 @@ Module::Module(const std::string &mname, const std::string &creator)
this->type = THIRD;
this->handle = NULL;
+ this->permanent = false;
+
for (int i = 0; i < NUM_LANGS; i++)
{
this->lang[i].argc = 0;
@@ -210,6 +212,16 @@ void Module::SetType(MODType ntype)
this->type = ntype;
}
+void Module::SetPermanent(bool state)
+{
+ this->permanent = state;
+}
+
+bool Module::GetPermanent()
+{
+ return this->permanent;
+}
+
void Module::SetVersion(const std::string &nversion)
{
this->version = nversion;
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 529a2e799..2a01351e1 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -229,7 +229,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
return MOD_ERR_OK;
}
-int ModuleManager::UnloadModule(Module * m, User * u)
+int ModuleManager::UnloadModule(Module *m, User *u)
{
if (!m || !m->handle)
{
@@ -238,7 +238,7 @@ int ModuleManager::UnloadModule(Module * m, User * u)
return MOD_ERR_PARAMS;
}
- if (m->type == PROTOCOL || m->type == ENCRYPTION)
+ if (m->GetPermanent() || m->type == PROTOCOL || m->type == ENCRYPTION)
{
if (u)
notice_lang(s_OperServ, u, OPER_MODULE_NO_UNLOAD);