diff options
Diffstat (limited to 'ports/common/guts')
-rw-r--r-- | ports/common/guts/execl.c | 13 | ||||
-rw-r--r-- | ports/common/guts/execle.c | 13 | ||||
-rw-r--r-- | ports/common/guts/execlp.c | 13 | ||||
-rw-r--r-- | ports/common/guts/execv.c | 36 | ||||
-rw-r--r-- | ports/common/guts/execve.c | 37 | ||||
-rw-r--r-- | ports/common/guts/execvp.c | 37 | ||||
-rw-r--r-- | ports/common/guts/fork.c | 24 |
7 files changed, 173 insertions, 0 deletions
diff --git a/ports/common/guts/execl.c b/ports/common/guts/execl.c new file mode 100644 index 0000000..ce908ed --- /dev/null +++ b/ports/common/guts/execl.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int execl(const char *file, const char *arg, va_list ap) + * int rc = -1; + */ + + rc = real_execl(file, arg, ap); + +/* return rc; + * } + */ diff --git a/ports/common/guts/execle.c b/ports/common/guts/execle.c new file mode 100644 index 0000000..68d8bba --- /dev/null +++ b/ports/common/guts/execle.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int execle(const char *file, const char *arg, va_list ap) + * int rc = -1; + */ + + rc = real_execle(file, arg, ap); + +/* return rc; + * } + */ diff --git a/ports/common/guts/execlp.c b/ports/common/guts/execlp.c new file mode 100644 index 0000000..d357986 --- /dev/null +++ b/ports/common/guts/execlp.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int execlp(const char *file, const char *arg, va_list ap) + * int rc = -1; + */ + + rc = real_execlp(file, arg, ap); + +/* return rc; + * } + */ diff --git a/ports/common/guts/execv.c b/ports/common/guts/execv.c new file mode 100644 index 0000000..15ad51e --- /dev/null +++ b/ports/common/guts/execv.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execv(const char *file, char *const *argv) { + * int rc = -1; + */ + /* 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. + */ + if (antimagic == 0) { + char *path_guess = pseudo_exec_path(file, 0); + pseudo_client_op(OP_EXEC, PSA_EXEC, -1, -1, path_guess, 0); + free(path_guess); + } + + if (!pseudo_get_value("PSEUDO_RELOADED")) + pseudo_setupenv(); + else { + pseudo_setupenv(); + pseudo_dropenv(); + } + + /* if exec() fails, we may end up taking signals unexpectedly... + * not much we can do about that. + */ + sigprocmask(SIG_SETMASK, &pseudo_saved_sigmask, NULL); + rc = real_execv(file, argv); + +/* return rc; + * } + */ diff --git a/ports/common/guts/execve.c b/ports/common/guts/execve.c new file mode 100644 index 0000000..a47b9a7 --- /dev/null +++ b/ports/common/guts/execve.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2008-2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execve(const char *file, 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. + */ + if (antimagic == 0) { + char *path_guess = pseudo_exec_path(file, 0); + pseudo_client_op(OP_EXEC, PSA_EXEC, -1, -1, path_guess, 0); + free(path_guess); + } + + if (!pseudo_get_value("PSEUDO_RELOADED")) + new_environ = pseudo_setupenvp(envp); + else { + new_environ = pseudo_setupenvp(envp); + new_environ = pseudo_dropenvp(new_environ); + } + + /* if exec() fails, we may end up taking signals unexpectedly... + * not much we can do about that. + */ + sigprocmask(SIG_SETMASK, &pseudo_saved_sigmask, NULL); + rc = real_execve(file, argv, new_environ); + +/* return rc; + * } + */ diff --git a/ports/common/guts/execvp.c b/ports/common/guts/execvp.c new file mode 100644 index 0000000..419f41b --- /dev/null +++ b/ports/common/guts/execvp.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2008-2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_execvp(const char *file, char *const *argv) { + * int rc = -1; + */ + + /* 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. + */ + if (antimagic == 0) { + char *path_guess = pseudo_exec_path(file, 1); + pseudo_client_op(OP_EXEC, PSA_EXEC, -1, -1, path_guess, 0); + free(path_guess); + } + + if (!pseudo_get_value("PSEUDO_RELOADED")) + pseudo_setupenv(); + else { + pseudo_setupenv(); + pseudo_dropenv(); + } + + /* if exec() fails, we may end up taking signals unexpectedly... + * not much we can do about that. + */ + sigprocmask(SIG_SETMASK, &pseudo_saved_sigmask, NULL); + rc = real_execvp(file, argv); + +/* return rc; + * } + */ diff --git a/ports/common/guts/fork.c b/ports/common/guts/fork.c new file mode 100644 index 0000000..76cac6f --- /dev/null +++ b/ports/common/guts/fork.c @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2008-2010 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * static int + * wrap_fork(void) { + * int rc = -1; + */ + rc = real_fork(); + /* special case: we may want to enable or disable + * pseudo in the child process + */ + if (rc == 0) { + if (!pseudo_get_value("PSEUDO_RELOADED")) { + pseudo_setupenv(); + pseudo_reinit_libpseudo(); + } else { + pseudo_setupenv(); + pseudo_dropenv(); + } + } +/* return rc; + * } + */ |