1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 06:06:39 +02:00

Modules wont load invalid revisions - NOT FULLY COMPLETE YET (altho it works to some degree)

git-svn-id: svn://svn.anope.org/anope/trunk@1065 31f1291d-b8d6-0310-a050-a5561fc1590b


git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@789 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b
2006-06-20 22:04:47 +00:00
parent 3a14edd254
commit a6f7ffef9b
6 changed files with 58 additions and 22 deletions
+3 -2
View File
@@ -2,12 +2,12 @@ MYSQL_OBJ = $(MYSQL:.c=.o)
RDB_OBJ = $(RDB:.c=.o)
OBJS = actions.o base64.o botserv.o channels.o chanserv.o commands.o compat.o \
config.o datafiles.o encrypt.o events.o helpserv.o hostserv.o init.o ircd.o language.o list.o log.o mail.o main.o \
memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \
memory.o memoserv.o messages.o misc.o mod_version.o modules.o news.o nickserv.o operserv.o \
process.o send.o servers.o sessions.o slist.o sockutil.o timeout.o users.o \
$(RDB_OBJ) $(MYSQL_OBJ)
SRCS = actions.c base64.c botserv.c channels.c chanserv.c commands.c compat.c \
config.c datafiles.c encrypt.c events.c helpserv.c hostserv.c init.c ircd.c language.c list.c log.c mail.c main.c \
memory.c memoserv.c messages.c misc.c modules.c news.c nickserv.c operserv.c \
memory.c memoserv.c messages.c misc.c mod_version.c modules.c news.c nickserv.c operserv.c \
process.c send.c servers.c sessions.c slist.c sockutil.c timeout.c users.c \
$(RDB) $(MYSQL)
@@ -60,6 +60,7 @@ memory.o: memory.c $(INCLUDES)
memoserv.o: memoserv.c $(INCLUDES)
messages.o: messages.c $(INCLUDES)
modules.o: modules.c $(INCLUDES)
mod_version.o: mod_version.c $(INCLUDES)
misc.o: misc.c $(INCLUDES)
news.o: news.c $(INCLUDES)
nickserv.o: nickserv.c $(INCLUDES)
+1 -1
View File
@@ -24,7 +24,7 @@ distclean: spotless
$(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} -I../${INCLUDEDIR} -c $<
.o.s:
$(CC) ${SHARED} $< -o $*.so ${PROFILE}
$(CC) ${SHARED} ../mod_version.o $< -o $*.so ${PROFILE}
@$(TOUCH) $*.s
subs:
+36
View File
@@ -0,0 +1,36 @@
#include "version.h"
#ifndef _WIN32
#define E extern
#define I extern
#else
#ifndef MODULE_COMPILE
#define E extern __declspec(dllexport)
#define I extern __declspec(dllimport)
#else
#define E extern __declspec(dllimport)
#define I extern __declspec(dllexport)
#endif
#endif
E int getAnopeBuildVersion();
E int getAnopeMajorVersion();
E int getAnopeMinorVersion();
E int getAnopePatchVersion();
int getAnopeBuildVersion() {
return VERSION_BUILD;
}
int getAnopeMajorVersion() {
return VERSION_MAJOR;
}
int getAnopeMinorVersion() {
return VERSION_MINOR;
}
int getAnopePatchVersion() {
return VERSION_PATCH;
}
+16 -17
View File
@@ -523,6 +523,7 @@ int loadModule(Module * m, User * u)
int len;
const char *err;
int (*func) (int, char **);
int (*version)();
int ret = 0;
char *argv[1];
int argc = 0;
@@ -557,8 +558,6 @@ int loadModule(Module * m, User * u)
buf[4095] = '\0';
/* Don't skip return value checking! -GD */
if ((ret = moduleCopyFile(m->name, buf)) != MOD_ERR_OK) {
if (u)
notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
m->filename = sstrdup(buf);
return ret;
}
@@ -568,22 +567,25 @@ int loadModule(Module * m, User * u)
m->handle = ano_modopen(m->filename);
if ((err = ano_moderr()) != NULL) {
alog(err);
if (u) {
notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
}
return MOD_ERR_NOLOAD;
}
ano_modclearerr();
func = (int (*)(int, char **))ano_modsym(m->handle, "AnopeInit");
if ((err = ano_moderr()) != NULL) {
ano_modclose(m->handle); /* If no AnopeInit - it isnt an Anope Module, close it */
if (u) {
notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
}
return MOD_ERR_NOLOAD;
}
if (func) {
version = (int (*)())ano_modsym(m->handle,"getAnopeBuildVersion");
if(version && version() >= VERSION_BUILD ) {
alog("Module %s compiled against anope revision %d, this is %d",m->name,version(),VERSION_BUILD);
} else {
ano_modclose(m->handle);
ano_modclearerr();
alog("Module %s is compiled against an old version of anope!",m->name);
return MOD_ERR_NOLOAD;
}
/* TODO */
mod_current_module_name = m->name;
/* argv[0] is the user if there was one, or NULL if not */
if (u) {
@@ -602,9 +604,6 @@ int loadModule(Module * m, User * u)
ret = MOD_STOP;
}
if (ret == MOD_STOP) {
if (u) {
notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
}
alog("%s requested unload...", m->name);
unloadModule(m, NULL);
mod_current_module_name = NULL;
@@ -623,10 +622,6 @@ int loadModule(Module * m, User * u)
return MOD_ERR_OK;
#else
if (u) {
notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
}
return MOD_ERR_NOLOAD;
#endif
}
@@ -2706,8 +2701,12 @@ void handleModuleOperationQueue(void)
alog("Trying to load module [%s]", mod_operation_queue->m->name);
status = loadModule(mod_operation_queue->m, mod_operation_queue->u);
alog("Module loading status: %d", status);
if (status != MOD_ERR_OK)
if (status != MOD_ERR_OK) {
if(mod_current_user) {
notice_lang(s_OperServ, mod_current_user, OPER_MODULE_LOAD_FAIL,mod_operation_queue->m->name);
}
destroyModule(mod_operation_queue->m);
}
} else if (mod_operation_queue->op == MOD_OP_UNLOAD) {
alog("Trying to unload module [%s]", mod_operation_queue->m->name);
status = unloadModule(mod_operation_queue->m, mod_operation_queue->u);
+1 -1
View File
@@ -24,7 +24,7 @@ distclean: spotless
$(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} -I../${INCLUDEDIR} -c $<
.o.s:
$(CC) ${SHARED} $< -o $*.so ${PROFILE}
$(CC) ${SHARED} ../mod_version.o $< -o $*.so ${PROFILE}
@$(TOUCH) $*.s
subs:
+1 -1
View File
@@ -24,7 +24,7 @@ distclean: clean spotless
$(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} -I../${INCLUDEDIR} -c $<
.o.s:
$(CC) ${SHARED} $< -o $*.so ${PROFILE}
$(CC) ${SHARED} ../mod_version.o $< -o $*.so ${PROFILE}
@$(TOUCH) $*.s
subs: