diff --git a/Makefile.in b/Makefile.in index 7f17cbf..73ca5f1 100755 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ OBJ=common.o vars.o iplist.o sockinfo.o actions.o exit.o hooks.o dl_hooks.o exec_hooks.o time_hooks.o file_hooks.o socket_hooks.o config.o net.o socks.o @X11_HOOKS_OBJ@ FLAGS=-g -fPIC @CFLAGS@ CC=gcc -VERSION=1.2 +VERSION=1.3 all: enhancer.so diff --git a/dl_hooks.c b/dl_hooks.c new file mode 100644 index 0000000..f74c09e --- /dev/null +++ b/dl_hooks.c @@ -0,0 +1,56 @@ +#include "common.h" +#include "config.h" +#include +#include +#include "hooks.h" + + +void *(*enhancer_real_dlopen)(const char *filename, int flag)=NULL; +int (*enhancer_real_dlclose)(void *handle)=NULL; + +void *dlopen(const char *path, int flags) +{ +char *Redirect=NULL; +int Flags; +void *handle; + +if (! enhancer_real_dlclose) enhancer_get_real_functions(); + +Flags=enhancer_checkconfig_with_redirect(FUNC_DLOPEN, "dlopen", path, "", flags, 0, &Redirect); + +if (Flags & FLAG_DENY) +{ + destroy(Redirect); + return(NULL); +} + +handle=enhancer_real_dlopen(Redirect, flags); +destroy(Redirect); + +return(handle); +} + + + + +int dlclose(void *handle) +{ +int Flags; + +if (! enhancer_real_dlclose) enhancer_get_real_functions(); + +Flags=enhancer_checkconfig_default(FUNC_DLCLOSE, "dlclose", "", "", 0, 0); +if (Flags & FLAG_DENY) return(-1); +if (Flags & FLAG_PRETEND) return(0); + +return(enhancer_real_dlclose(handle)); +} + + + + +void enhancer_dl_hooks() +{ +if (! enhancer_real_dlopen) enhancer_real_dlopen = dlsym(RTLD_NEXT, "dlopen"); +if (! enhancer_real_dlclose) enhancer_real_dlclose = dlsym(RTLD_NEXT, "dlclose"); +}