diff --git a/src/common.c b/src/common.c index 1da1c45..d843401 100644 --- a/src/common.c +++ b/src/common.c @@ -1,4 +1,5 @@ #include "common.h" +#include "debug.h" #include #include #include @@ -128,5 +129,11 @@ char *get_config_path(char* default_path, char* pbuf, size_t bufsize) { return NULL; have: + if(path[0] != '/') { + path = realpath(path, NULL); + setenv(PROXYCHAINS_CONF_FILE_ENV_VAR, path, 1); + free(path); + path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR); + } return path; } diff --git a/src/debug.h b/src/debug.h index 40a93d2..df1d978 100644 --- a/src/debug.h +++ b/src/debug.h @@ -5,7 +5,7 @@ #ifdef DEBUG # define PSTDERR(fmt, args...) do { dprintf(2,fmt, ## args); } while(0) -# define PDEBUG(fmt, args...) PSTDERR("DEBUG:"fmt, ## args) +# define PDEBUG(fmt, args...) PSTDERR("DEBUG:pid[%d]:"fmt, getpid(), ## args) # define DEBUGDECL(args...) args # define DUMP_PROXY_CHAIN(A, B) dump_proxy_chain(A, B) #else diff --git a/src/main.c b/src/main.c index ac10f89..219dc9a 100644 --- a/src/main.c +++ b/src/main.c @@ -135,6 +135,14 @@ int main(int argc, char *argv[]) { if(!quiet) fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name); + snprintf(path=pbuf, sizeof(pbuf), "%s/%s", prefix, dll_name); + if (path[0] != '/'){ + path = realpath(path, NULL); + snprintf(pbuf, sizeof(pbuf), "%s", path); + free(path); + path = pbuf; + } + #ifdef IS_MAC putenv("DYLD_FORCE_FLAT_NAMESPACE=1"); #define LD_PRELOAD_ENV "DYLD_INSERT_LIBRARIES" @@ -147,8 +155,8 @@ int main(int argc, char *argv[]) { #define LD_PRELOAD_SEP " " #endif char *old_val = getenv(LD_PRELOAD_ENV); - snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s/%s%s%s", - prefix, dll_name, + snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s%s%s", + path, /* append previous LD_PRELOAD content, if existent */ old_val ? LD_PRELOAD_SEP : "", old_val ? old_val : "");