aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-08 00:48:36 -0500
committerMike Frysinger <vapier@gentoo.org>2009-02-08 01:41:18 -0500
commit3aadb01e8252557563baaa469cb986fa7ccf11c6 (patch)
tree61c87019bd8076562c31bfc314d385657dccf58c /src
parentsb_printf: get z modifier working and fixup tests (diff)
downloadsandbox-3aadb01e8252557563baaa469cb986fa7ccf11c6.tar.gz
sandbox-3aadb01e8252557563baaa469cb986fa7ccf11c6.tar.bz2
sandbox-3aadb01e8252557563baaa469cb986fa7ccf11c6.zip
tests: get scripts working in sandbox.sh
Make sure we source the local sandbox.{bashrc,conf} and we always make the helper functions available when testing even if we aren't interactive. Now we can run `make check` and test the local version of sandbox even when we are running under another sandbox env. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/environ.c12
-rw-r--r--src/sandbox.c5
-rw-r--r--src/sandbox.sh.in5
3 files changed, 17 insertions, 5 deletions
diff --git a/src/environ.c b/src/environ.c
index e792f8d..e1002cc 100644
--- a/src/environ.c
+++ b/src/environ.c
@@ -78,6 +78,14 @@ error:
return NULL;
}
+static char *sb_conf_file(void)
+{
+ static char *conf_file;
+ if (!conf_file)
+ conf_file = get_sandbox_conf();
+ return conf_file;
+}
+
/* Get passed variable from sandbox.conf, and set it in the environment. */
static void setup_cfg_var(const char *env_var)
{
@@ -86,7 +94,7 @@ static void setup_cfg_var(const char *env_var)
/* We check if the variable is set in the environment, and if not, we
* get it from sandbox.conf, and if they exist, we just add them to the
* environment if not already present. */
- config = rc_get_cnf_entry(SANDBOX_CONF_FILE, env_var, NULL);
+ config = rc_get_cnf_entry(sb_conf_file(), env_var, NULL);
if (NULL != config) {
setenv(ENV_SANDBOX_VERBOSE, config, 0);
free(config);
@@ -107,7 +115,7 @@ static int setup_access_var(const char *access_var)
/* Now get the defaults for the access variable from sandbox.conf.
* These do not get overridden via the environment. */
- config = rc_get_cnf_entry(SANDBOX_CONF_FILE, access_var, ":");
+ config = rc_get_cnf_entry(sb_conf_file(), access_var, ":");
if (NULL != config) {
if (-1 == rc_dynbuf_write(env_data, config, strlen(config)))
goto error;
diff --git a/src/sandbox.c b/src/sandbox.c
index c9167f7..3c782ca 100644
--- a/src/sandbox.c
+++ b/src/sandbox.c
@@ -248,8 +248,9 @@ int main(int argc, char **argv)
dputs(sandbox_banner);
/* check if a sandbox is already running */
- if (NULL != getenv(ENV_SANDBOX_ACTIVE))
- sb_err("not launching a new sandbox as one is already running in this process hierarchy");
+ if (!is_env_on("__SANDBOX_TESTING"))
+ if (NULL != getenv(ENV_SANDBOX_ACTIVE))
+ sb_err("not launching a new sandbox as one is already running in this process hierarchy");
/* determine the location of all the sandbox support files */
dputs("Detection of the support files.");
diff --git a/src/sandbox.sh.in b/src/sandbox.sh.in
index 0f0ffbb..9324d20 100644
--- a/src/sandbox.sh.in
+++ b/src/sandbox.sh.in
@@ -1,7 +1,10 @@
#!/bin/sh
# quick wrapper to run local sandbox with local libsandbox
dir=${0%/*}
-export LD_LIBRARY_PATH=@abs_top_builddir@/libsandbox/.libs
+export abs_top_srcdir="@abs_top_srcdir@"
+export abs_top_builddir="@abs_top_builddir@"
+export LD_LIBRARY_PATH="${abs_top_builddir}/libsandbox/.libs"
+export __SANDBOX_TESTING=yes
if [ -x "${dir}"/sandbox ] ; then
exec "${dir}"/sandbox "$@"
else