diff options
author | 2009-03-08 08:21:22 -0400 | |
---|---|---|
committer | 2009-03-08 09:11:18 -0400 | |
commit | 7926384647f176889ec2e64e2351758b3d9bd099 (patch) | |
tree | 6dfe02d18e23a2e311abe4f331b3b57e0007f79b | |
parent | tests: add symlink tests and unify code (diff) | |
download | sandbox-7926384647f176889ec2e64e2351758b3d9bd099.tar.gz sandbox-7926384647f176889ec2e64e2351758b3d9bd099.tar.bz2 sandbox-7926384647f176889ec2e64e2351758b3d9bd099.zip |
sandbox: delete the testing var after installv1.4
We don't want people to bypass normal mechanisms with the testing var, so
zero out the name when installing the sandbox binary.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | libsbutil/get_sandbox_conf.c | 2 | ||||
-rw-r--r-- | libsbutil/get_sandbox_rc.c | 2 | ||||
-rw-r--r-- | libsbutil/sbutil.h | 3 | ||||
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/sandbox.c | 4 |
5 files changed, 14 insertions, 3 deletions
diff --git a/libsbutil/get_sandbox_conf.c b/libsbutil/get_sandbox_conf.c index 0f2f54b..af0140e 100644 --- a/libsbutil/get_sandbox_conf.c +++ b/libsbutil/get_sandbox_conf.c @@ -17,7 +17,7 @@ char *get_sandbox_conf(void) { char *ret = SANDBOX_CONF_FILE; save_errno(); - if (is_env_on("__SANDBOX_TESTING")) { + if (is_env_on(ENV_SANDBOX_TESTING)) { char *abs = getenv("abs_top_srcdir"); ret = xmalloc(strlen(abs) + strlen(LOCAL_SANDBOX_CONF_FILE) + 1); sprintf(ret, "%s%s", abs, LOCAL_SANDBOX_CONF_FILE); diff --git a/libsbutil/get_sandbox_rc.c b/libsbutil/get_sandbox_rc.c index 4a94e31..402ea9d 100644 --- a/libsbutil/get_sandbox_rc.c +++ b/libsbutil/get_sandbox_rc.c @@ -16,7 +16,7 @@ void get_sandbox_rc(char *path) { save_errno(); - if (is_env_on("__SANDBOX_TESTING")) + if (is_env_on(ENV_SANDBOX_TESTING)) snprintf(path, SB_PATH_MAX, "%s/data/%s", getenv("abs_top_srcdir"), BASHRC_NAME); else diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h index d45ee09..3e2d1bf 100644 --- a/libsbutil/sbutil.h +++ b/libsbutil/sbutil.h @@ -56,6 +56,9 @@ #define ENV_SANDBOX_VERBOSE "SANDBOX_VERBOSE" #define ENV_SANDBOX_DEBUG "SANDBOX_DEBUG" +extern const char env_sandbox_testing[]; +#define ENV_SANDBOX_TESTING env_sandbox_testing + #define ENV_SANDBOX_LIB "SANDBOX_LIB" #define ENV_SANDBOX_BASHRC "SANDBOX_BASHRC" #define ENV_SANDBOX_LOG "SANDBOX_LOG" diff --git a/src/Makefile.am b/src/Makefile.am index 2744542..b94bd9b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,3 +16,9 @@ sandbox_SOURCES = \ environ.c \ sandbox.h \ sandbox.c + +install-exec-hook: + sed -i.tmp \ + 's:__SANDBOX_TESTING:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:' \ + $(DESTDIR)$(bindir)/sandbox + rm -f $(DESTDIR)$(bindir)/sandbox.tmp diff --git a/src/sandbox.c b/src/sandbox.c index dd2f36c..5db43e0 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -26,6 +26,8 @@ static char log_domain[] = "sandbox"; static const char sandbox_banner[] = "============================= Gentoo path sandbox =============================="; static const char sandbox_footer[] = "--------------------------------------------------------------------------------"; +const char env_sandbox_testing[] = "__SANDBOX_TESTING"; + static int setup_sandbox(struct sandbox_info_t *sandbox_info, bool interactive) { if (NULL != getenv(ENV_PORTAGE_TMPDIR)) { @@ -250,7 +252,7 @@ int main(int argc, char **argv) dputs(sandbox_banner); /* check if a sandbox is already running */ - if (!is_env_on("__SANDBOX_TESTING")) + if (!is_env_on(ENV_SANDBOX_TESTING)) if (NULL != getenv(ENV_SANDBOX_ACTIVE)) sb_err("not launching a new sandbox as one is already running in this process hierarchy"); |