summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-07 19:29:46 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-07 19:29:46 +0000
commit2e7a94034d80daa745d062a42e9a7bbd88b4bc6d (patch)
treef5f4d94ecd46b19d332d8199176606697133f426 /src/inspircd.cpp
parentc3da4e977ae2bc451e2ec059bf3594dbd0b9c933 (diff)
Added module flags output to /MODULES
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1006 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index ee0780ddf..45f1ba474 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -3326,10 +3326,56 @@ bool UnloadModule(const char* filename)
return false;
}
+bool DirValid(char* dirandfile)
+{
+ char work[MAXBUF];
+ strlcpy(work,dirandfile,MAXBUF);
+ int p = strlen(work);
+ // we just want the dir
+ while (strlen(work))
+ {
+ if (work[p] == '/')
+ {
+ work[p] = '\0';
+ break;
+ }
+ work[p--] = '\0';
+ }
+ log(DEBUG,"Dir valid: %s",work);
+ char buffer[MAXBUF], otherdir[MAXBUF];
+ // Get the current working directory
+ if( getcwd( buffer, MAXBUF ) == NULL )
+ return false;
+ chdir(work);
+ if( getcwd( otherdir, MAXBUF ) == NULL )
+ return false;
+ chdir(buffer);
+ log(DEBUG,"Dir is really: %s",otherdir);
+ if (strlen(otherdir) >= strlen(work))
+ {
+ otherdir[strlen(work)] = '\0';
+ log(DEBUG,"Compare: '%s' -> '%s'",otherdir,work);
+ if (!strcmp(otherdir,work))
+ {
+ log(DEBUG,"Match ok");
+ return true;
+ }
+ log(DEBUG,"No match");
+ return false;
+ }
+ else return false;
+}
+
bool LoadModule(const char* filename)
{
char modfile[MAXBUF];
- snprintf(modfile,MAXBUF,"%s/%s",MOD_PATH,filename,&config_f);
+ snprintf(modfile,MAXBUF,"%s/%s",MOD_PATH,filename);
+ if (!DirValid(modfile))
+ {
+ log(DEFAULT,"Module %s is not within the modules directory.",modfile);
+ snprintf(MODERR,MAXBUF,"Module %s is not within the modules directory.",modfile);
+ return false;
+ }
log(DEBUG,"Loading module: %s",modfile);
if (FileExists(modfile))
{