aboutsummaryrefslogtreecommitdiff
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 /libsbutil/get_sandbox_conf.c
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 'libsbutil/get_sandbox_conf.c')
-rw-r--r--libsbutil/get_sandbox_conf.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libsbutil/get_sandbox_conf.c b/libsbutil/get_sandbox_conf.c
new file mode 100644
index 0000000..0f2f54b
--- /dev/null
+++ b/libsbutil/get_sandbox_conf.c
@@ -0,0 +1,27 @@
+/*
+ * get_sandbox_conf.c
+ *
+ * Util functions.
+ *
+ * Copyright 1999-2008 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+#include "headers.h"
+#include "sbutil.h"
+
+/* Where the file exists in our source tree */
+#define LOCAL_SANDBOX_CONF_FILE "/etc/sandbox.conf"
+
+char *get_sandbox_conf(void)
+{
+ char *ret = SANDBOX_CONF_FILE;
+ save_errno();
+ if (is_env_on("__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);
+ }
+ restore_errno();
+ return ret;
+}