diff options
author | 2009-03-12 07:25:40 -0400 | |
---|---|---|
committer | 2009-03-12 09:07:07 -0400 | |
commit | 12e00f1199e029554ed250fea1f6c95ca62baf2b (patch) | |
tree | 1acd69e768955c26c5e0f4185a7acbefbcda071c /src | |
parent | libsandbox: unify getcwd wrapper with common wrappers (diff) | |
download | sandbox-12e00f1199e029554ed250fea1f6c95ca62baf2b.tar.gz sandbox-12e00f1199e029554ed250fea1f6c95ca62baf2b.tar.bz2 sandbox-12e00f1199e029554ed250fea1f6c95ca62baf2b.zip |
sandbox: don't put duplicate sandbox.so into LD_PRELOADv1.6
If launching another sandbox instance, don't blindly append LD_PRELOAD
with the sandbox lib.
URL: http://bugs.gentoo.org/216942
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reported-by: Brian Harring <ferringb@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/environ.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/environ.c b/src/environ.c index e1002cc..9cc337c 100644 --- a/src/environ.c +++ b/src/environ.c @@ -262,16 +262,20 @@ char **setup_environ(struct sandbox_info_t *sandbox_info, bool interactive) unsetenv(ENV_SANDBOX_INTRACTV); unsetenv(ENV_BASH_ENV); - if (NULL != getenv(ENV_LD_PRELOAD)) { - have_ld_preload = 1; - orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD); - - ld_preload_envvar = xcalloc(strlen(orig_ld_preload_envvar) + - strlen(sandbox_info->sandbox_lib) + 2, - sizeof(char)); - snprintf(ld_preload_envvar, strlen(orig_ld_preload_envvar) + - strlen(sandbox_info->sandbox_lib) + 2, "%s %s", - sandbox_info->sandbox_lib, orig_ld_preload_envvar); + orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD); + if (orig_ld_preload_envvar) { + if (!strstr(orig_ld_preload_envvar, sandbox_info->sandbox_lib)) { + have_ld_preload = 1; + ld_preload_envvar = xcalloc(strlen(orig_ld_preload_envvar) + + strlen(sandbox_info->sandbox_lib) + 2, + sizeof(char)); + snprintf(ld_preload_envvar, strlen(orig_ld_preload_envvar) + + strlen(sandbox_info->sandbox_lib) + 2, "%s %s", + sandbox_info->sandbox_lib, orig_ld_preload_envvar); + } else { + have_ld_preload = 2; + ld_preload_envvar = NULL; + } } else ld_preload_envvar = xstrdup(sandbox_info->sandbox_lib); /* Do not unset this, as strange things might happen */ @@ -299,7 +303,7 @@ char **setup_environ(struct sandbox_info_t *sandbox_info, bool interactive) if (!getenv(ENV_NOCOLOR)) sb_setenv(&new_environ, ENV_NOCOLOR, "no"); /* If LD_PRELOAD was not set, set it here, else do it below */ - if (1 != have_ld_preload) + if (!have_ld_preload) sb_setenv(&new_environ, ENV_LD_PRELOAD, ld_preload_envvar); /* Make sure our bashrc gets preference */ |