summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrostycoolslug <frostycoolslug@e03df62e-2008-0410-955e-edbf42e46eb7>2003-09-27 04:02:46 +0000
committerfrostycoolslug <frostycoolslug@e03df62e-2008-0410-955e-edbf42e46eb7>2003-09-27 04:02:46 +0000
commit22acc84215d3e70d0ce4c9989f3d3c4449babddf (patch)
tree88158d3973331fa80a3e8f4245d13a833ae8a7bf /src
parent1705c98dbe6e013c22afb098345542efbdd403d4 (diff)
Fixed Bug Causing missing modules to Seg Fault The IRCd, now the missing modules are ignored.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@188 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp47
-rw-r--r--src/inspircd_io.cpp10
2 files changed, 40 insertions, 17 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 3674c55a7..065e94524 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -4067,32 +4067,47 @@ int InspIRCd(void)
log(DEBUG,"InspIRCd: startup: InspIRCd is now running!");
printf("\n");
- for (count = 0; count < ConfValueEnum("module"); count++)
+
+ /* BugFix By Craig! :p */
+ count2 = 0;
+ for (count = 0; count2 < ConfValueEnum("module"); count2++)
{
char modfile[MAXBUF];
ConfValue("module","name",count,configToken);
sprintf(modfile,"%s/%s",MOD_PATH,configToken);
printf("Loading module... \033[1;37m%s\033[0;37m\n",modfile);
log(DEBUG,"InspIRCd: startup: Loading module: %s",modfile);
-
- factory[count] = new ircd_module(modfile);
- if (factory[count]->LastError())
+ /* If The File Doesnt exist, Trying to load it
+ * Will Segfault the IRCd.. So, check to see if
+ * it Exists, Before Proceeding. */
+ if (CheckModule(modfile))
{
- log(DEBUG,"Unable to load %s: %s",modfile,factory[count]->LastError());
- sprintf("Unable to load %s: %s\nExiting...\n",modfile,factory[count]->LastError());
- Exit(ERROR);
- }
- if (factory[count]->factory)
- {
- modules[count] = factory[count]->factory->CreateModule();
- /* save the module and the module's classfactory, if
- * this isnt done, random crashes can occur :/ */
+ factory[count] = new ircd_module(modfile);
+ if (factory[count]->LastError())
+ {
+ log(DEBUG,"Unable to load %s: %s",modfile,factory[count]->LastError());
+ sprintf("Unable to load %s: %s\nExiting...\n",modfile,factory[count]->LastError());
+ Exit(ERROR);
+ }
+ if (factory[count]->factory)
+ {
+ modules[count] = factory[count]->factory->CreateModule();
+ /* save the module and the module's classfactory, if
+ * this isnt done, random crashes can occur :/ */
+ }
+ else
+ {
+ log(DEBUG,"Unable to load %s",modfile);
+ sprintf("Unable to load %s\nExiting...\n",modfile);
+ Exit(ERROR);
+ }
+ /* Increase the Count */
+ count++;
}
else
{
- log(DEBUG,"Unable to load %s",modfile);
- sprintf("Unable to load %s\nExiting...\n",modfile);
- Exit(ERROR);
+ log(DEBUG,"InspIRCd: startup: Module Not Found %s",modfile);
+ printf("Module Not Found: \033[1;37m%s\033[0;37m, Skipping\n",modfile);
}
}
MODCOUNT = count - 1;
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 366fa799c..f1e7bf66c 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -85,7 +85,15 @@ int DaemonSeed (void)
}
-
+/* Make Sure Modules Are Avaliable!
+ * (BugFix By Craig.. See? I do work! :p) */
+int CheckModule (char module[MAXBUF])
+{
+ FILE *input;
+
+ if ((input = fopen (module, "r")) == NULL) { return(FALSE); }
+ else { fclose (input); return(TRUE); }
+}
/* Make sure the config file is available */
int CheckConfig (void)