summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-06-21 20:46:29 -0400
committerAdam <Adam@anope.org>2017-06-21 20:46:29 -0400
commit46acfd0490bee851ef82897fa6a7686f64b2544e (patch)
tree3ad9859ba7220cb509d57dfde31d99c242586267
parentcd9895561bd597b52b27c79f0c74a9e6c522d688 (diff)
Stop init if a module can't be loaded because it doesn't exist
-rw-r--r--src/init.cpp11
-rw-r--r--src/modulemanager.cpp7
2 files changed, 17 insertions, 1 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 6c69580c6..aed6b8a24 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -543,7 +543,16 @@ void Anope::Init(int ac, char **av)
/* load modules */
Anope::Logger.Log("Loading modules...");
for (int i = 0; i < Config->CountBlock("module"); ++i)
- ModuleManager::LoadModule(Config->GetBlock("module", i)->Get<Anope::string>("name"), NULL);
+ {
+ Configuration::Block *config = Config->GetBlock("module", i);
+
+ ModuleReturn modret = ModuleManager::LoadModule(config->Get<Anope::string>("name"), NULL);
+
+ if (modret == ModuleReturn::NOEXIST)
+ {
+ throw CoreException("Module " + config->Get<Anope::string>("name") + " does not exist!");
+ }
+ }
Config->LoadOpers();
Config->ApplyBots();
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index a8cfbd547..661519ca4 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -157,6 +157,13 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
}
#else
Anope::string pbuf = Anope::ModuleDir + "/modules/" + modname.replace_all_cs("/", "_") + ".so";
+
+ struct stat s;
+ if (stat(pbuf.c_str(), &s) == -1 || !S_ISREG(s.st_mode))
+ {
+ Anope::Logger.Terminal(_("Error while loading {0} (file does not exist)"), modname);
+ return ModuleReturn::NOEXIST;
+ }
#endif
dlerror();