aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2010-04-26 17:03:10 -0700
committerPeter Seebach <peter.seebach@windriver.com>2010-04-26 17:13:45 -0700
commitb0dc7011bb3efb160223fd759544de9987129d99 (patch)
treedde56392a990d0a01627a305be5cbe7236983a67 /guts
parentcc00abcd92f3d1c491d262266115dcee71b9a7a1 (diff)
downloadpseudo-b0dc7011bb3efb160223fd759544de9987129d99.tar.gz
pseudo-b0dc7011bb3efb160223fd759544de9987129d99.tar.bz2
pseudo-b0dc7011bb3efb160223fd759544de9987129d99.zip
Handle execve() better
You can't use setenv() to modify the environment that will be passed to a child process through execve()... Also, fix the setupenv() to use PSEUDO_SUFFIX if defined. Use execve() to spawn child processes, so we can use setupenv() and dropenv().
Diffstat (limited to 'guts')
-rw-r--r--guts/execve.c9
-rw-r--r--guts/fork.c1
2 files changed, 7 insertions, 3 deletions
diff --git a/guts/execve.c b/guts/execve.c
index 1dda551..ccbc9c7 100644
--- a/guts/execve.c
+++ b/guts/execve.c
@@ -6,14 +6,19 @@
* wrap_execve(const char *filename, char *const *argv, char *const *envp) {
* int rc = -1;
*/
+ char * const *new_environ;
/* note: we don't canonicalize this, because we are intentionally
* NOT redirecting execs into the chroot environment. If you try
* to execute /bin/sh, you get the actual /bin/sh, not
* <CHROOT>/bin/sh. This allows use of basic utilities. This
* design will likely be revisited.
*/
- pseudo_client_op(OP_EXEC, PSA_EXEC, 0, 0, filename, 0);
- rc = real_execve(filename, argv, envp);
+ pseudo_client_op(OP_EXEC, PSA_EXEC, -1, 0, filename, 0);
+ if (!getenv("PSEUDO_RELOADED"))
+ new_environ = pseudo_setupenv(envp, getenv("PSEUDO_OPTS"));
+ else
+ new_environ = envp;
+ rc = real_execve(filename, argv, new_environ);
/* return rc;
* }
diff --git a/guts/fork.c b/guts/fork.c
index f4eb7f6..4a91f7b 100644
--- a/guts/fork.c
+++ b/guts/fork.c
@@ -6,7 +6,6 @@
* wrap_fork(void) {
* int rc = -1;
*/
-
rc = real_fork();
if (rc == 0)
pseudo_client_reset();