summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-04-26 12:06:09 -0400
committerMike Frysinger <vapier@gentoo.org>2009-04-26 12:06:09 -0400
commit5b28e3905a24f17fbbaedbe692f19c4bd9b57b5e (patch)
treef1fdb2284c9e4555628be17d0071677c1d9c6253
parenttests: use AUTOTEST_PATH rather than setting PATH manually (diff)
downloadsandbox-5b28e3905a24f17fbbaedbe692f19c4bd9b57b5e.tar.gz
sandbox-5b28e3905a24f17fbbaedbe692f19c4bd9b57b5e.tar.bz2
sandbox-5b28e3905a24f17fbbaedbe692f19c4bd9b57b5e.zip
setup local sandbox.d for running tests to avoid /etc/sandbox.d
Always use local sandbox.d copy to avoid random /etc/sandbox.d issues like it doesn't exist, or has permission problems, or anything else. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--configure.ac1
-rw-r--r--etc/Makefile.am6
-rw-r--r--etc/sandbox.d/00default (renamed from etc/00default)0
-rw-r--r--etc/sandbox.d/Makefile.am2
-rw-r--r--libsbutil/Makefile.am1
-rw-r--r--libsbutil/get_sandbox_confd.c23
-rw-r--r--libsbutil/sbutil.h1
-rw-r--r--src/environ.c3
8 files changed, 32 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 232794a..ebb9192 100644
--- a/configure.ac
+++ b/configure.ac
@@ -408,6 +408,7 @@ AC_CONFIG_FILES([
Makefile
scripts/Makefile
etc/Makefile
+ etc/sandbox.d/Makefile
data/Makefile
libsbutil/Makefile
libsandbox/Makefile
diff --git a/etc/Makefile.am b/etc/Makefile.am
index 3425f1b..1640a57 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -1,6 +1,4 @@
+SUBDIRS = sandbox.d
+
confdir = $(sysconfdir)
dist_conf_DATA = sandbox.conf
-
-confddir = $(sysconfdir)/sandbox.d
-dist_confd_DATA = 00default
-
diff --git a/etc/00default b/etc/sandbox.d/00default
index a419480..a419480 100644
--- a/etc/00default
+++ b/etc/sandbox.d/00default
diff --git a/etc/sandbox.d/Makefile.am b/etc/sandbox.d/Makefile.am
new file mode 100644
index 0000000..b8195ff
--- /dev/null
+++ b/etc/sandbox.d/Makefile.am
@@ -0,0 +1,2 @@
+confddir = $(sysconfdir)/sandbox.d
+dist_confd_DATA = 00default
diff --git a/libsbutil/Makefile.am b/libsbutil/Makefile.am
index 4a82d62..8975201 100644
--- a/libsbutil/Makefile.am
+++ b/libsbutil/Makefile.am
@@ -15,6 +15,7 @@ libsbutil_la_LDFLAGS = -no-undefined
libsbutil_la_SOURCES = \
sbutil.h \
get_sandbox_conf.c \
+ get_sandbox_confd.c \
get_sandbox_lib.c \
get_sandbox_rc.c \
get_sandbox_log.c \
diff --git a/libsbutil/get_sandbox_confd.c b/libsbutil/get_sandbox_confd.c
new file mode 100644
index 0000000..ffe3021
--- /dev/null
+++ b/libsbutil/get_sandbox_confd.c
@@ -0,0 +1,23 @@
+/*
+ * get_sandbox_confd.c
+ *
+ * Util functions.
+ *
+ * Copyright 1999-2009 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+#include "headers.h"
+#include "sbutil.h"
+
+char *get_sandbox_confd(char *path)
+{
+ save_errno();
+ if (is_env_on(ENV_SANDBOX_TESTING))
+ snprintf(path, SB_PATH_MAX, "%s/etc/sandbox.d/",
+ getenv("abs_top_srcdir"));
+ else
+ strcpy(path, SANDBOX_CONFD_DIR);
+ restore_errno();
+ return path;
+}
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index d76e0c9..523cf01 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -81,6 +81,7 @@ extern const char env_sandbox_testing[];
#define SB_EERROR(_hilight, _args...) sb_efunc(COLOR_RED, _hilight, _args)
char *get_sandbox_conf(void);
+char *get_sandbox_confd(char *path);
void get_sandbox_lib(char *path);
void get_sandbox_rc(char *path);
void get_sandbox_log(char *path);
diff --git a/src/environ.c b/src/environ.c
index b6d9550..8f4968f 100644
--- a/src/environ.c
+++ b/src/environ.c
@@ -107,6 +107,7 @@ static int setup_access_var(const char *access_var)
{
rc_dynbuf_t *env_data;
int count = 0;
+ char confd_path[SB_PATH_MAX];
char *config;
char **confd_files = NULL;
bool use_confd = true;
@@ -136,7 +137,7 @@ static int setup_access_var(const char *access_var)
/* Now scan the files in sandbox.d/ if the access variable was not
* alreay set. */
- confd_files = rc_ls_dir(SANDBOX_CONFD_DIR, false, true);
+ confd_files = rc_ls_dir(get_sandbox_confd(confd_path), false, true);
if (NULL != confd_files) {
while (NULL != confd_files[count]) {
config = rc_get_cnf_entry(confd_files[count], access_var, ":");