aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-01-26 00:50:16 -0500
committerMike Frysinger <vapier@gentoo.org>2009-01-26 00:50:16 -0500
commit1d8dac7eee63b01e70239872e297d60994f08865 (patch)
treeb7ef7197a270ac7b376772fd5e3c327aa743c08a
parentsandbox.bashrc: provide simple fallback e* msg funcs (diff)
downloadsandbox-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>
-rw-r--r--libsbutil/get_sandbox_lib.c12
-rw-r--r--src/Makefile.am4
2 files changed, 12 insertions, 4 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();
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f25419..bb59ccb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,10 +13,8 @@ INCLUDES = \
-I$(top_srcdir)/libsbutil \
-I$(top_srcdir)/libsbutil/include
-sandbox_CFLAGS = -DOUTSIDE_LIBSANDBOX
-sandbox_LDADD = $(top_builddir)/libsbutil/libsbutil.la
+sandbox_LDADD = $(top_builddir)/libsbutil/libsbutil.la -ldl
sandbox_SOURCES = \
environ.c \
sandbox.h \
sandbox.c
-