diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-01-26 00:50:16 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-01-26 00:50:16 -0500 |
commit | 1d8dac7eee63b01e70239872e297d60994f08865 (patch) | |
tree | b7ef7197a270ac7b376772fd5e3c327aa743c08a /libsbutil/get_sandbox_lib.c | |
parent | sandbox.bashrc: provide simple fallback e* msg funcs (diff) | |
download | sandbox-1d8dac7eee63b01e70239872e297d60994f08865.tar.gz sandbox-1d8dac7eee63b01e70239872e297d60994f08865.tar.bz2 sandbox-1d8dac7eee63b01e70239872e297d60994f08865.zip |
libsbutil: find libsandbox.so in non-standard paths
If installing sandbox into a non-standard location (and the library ends up
in a non-standard path where the ELF loader does not search), then set the
LD_PRELOAD variable to the full path.
URL: http://bugs.gentoo.org/254358
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reported-by: Jeremy Olexa <darkside@gentoo.org>
Diffstat (limited to 'libsbutil/get_sandbox_lib.c')
-rw-r--r-- | libsbutil/get_sandbox_lib.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libsbutil/get_sandbox_lib.c b/libsbutil/get_sandbox_lib.c index da88724..b64a5ac 100644 --- a/libsbutil/get_sandbox_lib.c +++ b/libsbutil/get_sandbox_lib.c @@ -15,10 +15,20 @@ /* Always let the dynamic loader do the searching rather than hard coding the * full path. This way, things like multilib, testing, local runs work easier. + * + * Make an exception for non-standard setups (i.e. prefix) where libsandbox is + * installed into a path that is not in ld.so.conf. */ void get_sandbox_lib(char *path) { save_errno(); - snprintf(path, SB_PATH_MAX, "%s", LIB_NAME); + strcpy(path, LIB_NAME); + if (strncmp("/usr/lib", LIBSANDBOX_PATH, 8)) { + void *hndl = dlopen(path, RTLD_LAZY); + if (!hndl) + snprintf(path, SB_PATH_MAX, "%s/%s", LIBSANDBOX_PATH, LIB_NAME); + else + dlclose(hndl); + } restore_errno(); } |