From ed7c89072a4bb1ccdc500410b3bfa4b01fff0679 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Wed, 9 Jul 2014 19:12:30 +0200 Subject: [PATCH] main.c: append previously existing LD_PRELOAD contents rather than overwriting some broken programs like pulseaudio rely on LD_PRELOAD hacks to function, if we just override the environment variable, those will stop working. simplified version of patch suggested by @hexchain closes #35 --- src/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index c67cde4..b7e5e3a 100644 --- a/src/main.c +++ b/src/main.c @@ -125,10 +125,20 @@ int main(int argc, char *argv[]) { #ifdef IS_MAC putenv("DYLD_FORCE_FLAT_NAMESPACE=1"); #define LD_PRELOAD_ENV "DYLD_INSERT_LIBRARIES" +#define LD_PRELOAD_SEP ":" #else #define LD_PRELOAD_ENV "LD_PRELOAD" +/* all historic implementations of BSD and linux dynlinkers seem to support + space as LD_PRELOAD separator, with colon added only recently. + we use the old syntax for maximum compat */ +#define LD_PRELOAD_SEP " " #endif - snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s/%s", prefix, dll_name); + char *old_val = getenv(LD_PRELOAD_ENV); + snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s/%s%s%s", + prefix, dll_name, + /* append previous LD_PRELOAD content, if existent */ + old_val ? LD_PRELOAD_SEP : "", + old_val ? old_val : ""); putenv(buf); execvp(argv[start_argv], &argv[start_argv]); perror("proxychains can't load process....");