aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_wrappers.c
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2010-08-10 11:30:18 -0500
committerPeter Seebach <seebs@laptop-seebs-net.local>2010-08-11 14:38:11 -0500
commit5d027f78a6e677e9272a17555a83124026e6fb08 (patch)
treed82c988b997f8889734d09ce72dd7433a353ef50 /pseudo_wrappers.c
parenta6a473ab1bac9c4b11049653f3b344d827c380c5 (diff)
downloadpseudo-5d027f78a6e677e9272a17555a83124026e6fb08.tar.gz
pseudo-5d027f78a6e677e9272a17555a83124026e6fb08.tar.bz2
pseudo-5d027f78a6e677e9272a17555a83124026e6fb08.zip
Enable local variable cache
Add local variable cache via get_value and set_value. The local cache is setup at constructor time (or soon after). Rewrite the pseudo_setupenv and pseudo_dropenv routines, add a new pseudo_setupenvp and pseudo_dropenvp as well to handle the execve cases. We can now successfully use /usr/bin/env -i env and get pseudo values back!
Diffstat (limited to 'pseudo_wrappers.c')
-rw-r--r--pseudo_wrappers.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
index 4e98efa..d7ed9f6 100644
--- a/pseudo_wrappers.c
+++ b/pseudo_wrappers.c
@@ -1,6 +1,7 @@
/* wrapper code -- this is the shared code used around the pseduo
* wrapper functions, which are in pseudo_wrapfuncs.c.
*/
+#include <assert.h>
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
@@ -84,8 +85,10 @@ pseudo_magic() {
static void
pseudo_enosys(const char *func) {
pseudo_diag("pseudo: ENOSYS for '%s'.\n", func ? func : "<nil>");
- if (getenv("PSEUDO_ENOSYS_ABORT"))
+ char * value = pseudo_get_value("PSEUDO_ENOSYS_ABORT");
+ if (value)
abort();
+ free(value);
}
/* de-chroot a string.
@@ -143,14 +146,15 @@ pseudo_populate_wrappers(void) {
}
}
done = 1;
- debug = getenv("PSEUDO_DEBUG");
+ debug = pseudo_get_value("PSEUDO_DEBUG");
if (debug) {
int level = atoi(debug);
for (i = 0; i < level; ++i) {
pseudo_debug_verbose();
}
}
- no_symlink_exp = getenv("PSEUDO_NOSYMLINKEXP");
+ free(debug);
+ no_symlink_exp = pseudo_get_value("PSEUDO_NOSYMLINKEXP");
if (no_symlink_exp) {
char *endptr;
/* if the environment variable is not an empty string,
@@ -171,6 +175,7 @@ pseudo_populate_wrappers(void) {
} else {
pseudo_nosymlinkexp = 0;
}
+ free(no_symlink_exp);
/* if PSEUDO_DEBUG_FILE is set up, redirect logging there.
*/
pseudo_logfile(NULL);
@@ -185,33 +190,35 @@ pseudo_populate_wrappers(void) {
if (pseudo_path) {
pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY);
pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, MOVE_FD);
- free(pseudo_path);
} else {
pseudo_diag("No prefix available to to find server.\n");
exit(1);
}
if (pseudo_prefix_dir_fd == -1) {
- pseudo_diag("Can't open prefix path (%s) for server.\n",
+ pseudo_diag("Can't open prefix path (%s) for server: %s\n",
+ pseudo_path,
strerror(errno));
exit(1);
}
}
+ free(pseudo_path);
pseudo_path = pseudo_localstatedir_path(NULL);
if (pseudo_localstate_dir_fd == -1) {
if (pseudo_path) {
pseudo_localstate_dir_fd = open(pseudo_path, O_RDONLY);
pseudo_localstate_dir_fd = pseudo_fd(pseudo_localstate_dir_fd, MOVE_FD);
- free(pseudo_path);
} else {
pseudo_diag("No prefix available to to find server.\n");
exit(1);
}
if (pseudo_localstate_dir_fd == -1) {
- pseudo_diag("Can't open prefix path (%s) for server.\n",
+ pseudo_diag("Can't open prefix path (%s) for server: %s\n",
+ pseudo_path,
strerror(errno));
exit(1);
}
}
+ free(pseudo_path);
pseudo_debug(2, "(%s) set up wrappers\n", program_invocation_short_name);
pseudo_magic();
pseudo_droplock();