summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd_io.h1
-rw-r--r--src/inspircd.cpp47
-rw-r--r--src/inspircd_io.cpp10
3 files changed, 41 insertions, 17 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index 3270c2bc4..b4955bacb 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -17,6 +17,7 @@
void Exit (int);
void Start (void);
int DaemonSeed (void);
+int CheckModule (char module[MAXBUF]);
int CheckConfig (void);
int OpenTCPSocket (void);
int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr);
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)