Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "common.h"
#include "debug.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
Expand Down Expand Up @@ -94,5 +95,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;
}
2 changes: 1 addition & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifdef DEBUG
# include <stdio.h>
# 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

# include "core.h"
Expand Down
12 changes: 10 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,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"
Expand All @@ -143,8 +151,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 : "");
Expand Down