aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2010-12-02 14:29:36 -0600
committerPeter Seebach <peter.seebach@windriver.com>2010-12-02 14:29:36 -0600
commit7b2dd4c7a6e20a8fe78cb892a8406d6d119c415b (patch)
treea9ec15c62eb2faf83731a5f58192811a21058e83 /guts
parent7b36402ecfb7dffdcbc24f36119099cfb8c4dccf (diff)
downloadpseudo-7b2dd4c7a6e20a8fe78cb892a8406d6d119c415b.tar.gz
pseudo-7b2dd4c7a6e20a8fe78cb892a8406d6d119c415b.tar.bz2
pseudo-7b2dd4c7a6e20a8fe78cb892a8406d6d119c415b.zip
Major shift: Fix execl*(), allow enabling/disabling pseudo with
an environment variable across fork(). This does a couple of things. One is, move the fork/vfork and execl* functions out of the standard wrapper environment. Having done that, the execl*() wrappers are rewritten so they can use real_execv*() when running in antimagic mode. This allows us to run pseudo entirely in antimagic mode. Which is handy, because we also add support for enabling/disabling antimagic mode in the child process on a fork, using an additional hook for this in the pseudo_client_init() routine. The redone fork() wrapper now calls pseudo_client_init() in the child process after a successful fork even if it's in antimagic mode already. This is not yet well-tested.
Diffstat (limited to 'guts')
-rw-r--r--guts/execl.c42
-rw-r--r--guts/execle.c44
-rw-r--r--guts/execlp.c42
-rw-r--r--guts/vfork.c17
4 files changed, 0 insertions, 145 deletions
diff --git a/guts/execl.c b/guts/execl.c
deleted file mode 100644
index ca2df70..0000000
--- a/guts/execl.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010 Wind River Systems; see
- * guts/COPYRIGHT for information.
- *
- * static int
- * wrap_execl(const char *file, const char *arg, va_list ap) {
- * int rc = -1;
- */
-
- size_t i = 0;
- size_t alloc_size = 256;
- const char **argv = malloc(sizeof (const char *) * alloc_size);
- if (!argv) {
- pseudo_debug(1, "execl failed: couldn't allocate memory for %lu arguments\n",
- (unsigned long) alloc_size);
- errno = ENOMEM;
- return -1;
- }
-
- argv[i++] = arg;
-
- while (argv[i-1]) {
- argv[i++] = va_arg (ap, const char *);
- if ( i > alloc_size - 1 ) {
- alloc_size = alloc_size + 256;
- argv = realloc(argv, sizeof (const char *) * alloc_size);
- if (!argv) {
- pseudo_debug(1, "execl failed: couldn't allocate memory for %lu arguments\n",
- (unsigned long) alloc_size);
- errno = ENOMEM;
- return -1;
- }
- }
- }
-
- rc = wrap_execv (file, (char *const *) argv);
-
- free (argv);
-
-/* return rc;
- * }
- */
diff --git a/guts/execle.c b/guts/execle.c
deleted file mode 100644
index 5b44d78..0000000
--- a/guts/execle.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2010 Wind River Systems; see
- * guts/COPYRIGHT for information.
- *
- * static int
- * wrap_execle(const char *file, const char *arg, va_list ap) {
- * int rc = -1;
- */
-
- size_t i = 0;
- size_t alloc_size = 256;
- const char **argv = malloc(sizeof (const char *) * alloc_size);
- char *const *envp;
- if (!argv) {
- pseudo_debug(1, "execle failed: couldn't allocate memory for %lu arguments\n",
- (unsigned long) alloc_size);
- errno = ENOMEM;
- return -1;
- }
-
- argv[i++] = arg;
-
- while (argv[i-1]) {
- argv[i++] = va_arg (ap, const char *);
- if ( i > alloc_size - 1 ) {
- alloc_size = alloc_size + 256;
- argv = realloc(argv, sizeof (const char *) * alloc_size);
- if (!argv) {
- pseudo_debug(1, "execle failed: couldn't allocate memory for %lu arguments\n",
- (unsigned long) alloc_size);
- errno = ENOMEM;
- return -1;
- }
- }
- }
- envp = va_arg (ap, char *const *);
-
- rc = wrap_execve (file, (char *const *) argv, envp);
-
- free (argv);
-
-/* return rc;
- * }
- */
diff --git a/guts/execlp.c b/guts/execlp.c
deleted file mode 100644
index d09a64d..0000000
--- a/guts/execlp.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010 Wind River Systems; see
- * guts/COPYRIGHT for information.
- *
- * static int
- * wrap_execlp(const char *file, const char *arg, va_list ap) {
- * int rc = -1;
- */
-
- size_t i = 0;
- size_t alloc_size = 256;
- const char **argv = malloc(sizeof (const char *) * alloc_size);
- if (!argv) {
- pseudo_debug(1, "execlp failed: couldn't allocate memory for %lu arguments\n",
- (unsigned long) alloc_size);
- errno = ENOMEM;
- return -1;
- }
-
- argv[i++] = arg;
-
- while (argv[i-1]) {
- argv[i++] = va_arg (ap, const char *);
- if ( i > alloc_size - 1 ) {
- alloc_size = alloc_size + 256;
- argv = realloc(argv, sizeof (const char *) * alloc_size);
- if (!argv) {
- pseudo_debug(1, "execlp failed: couldn't allocate memory for %lu arguments\n",
- (unsigned long) alloc_size);
- errno = ENOMEM;
- return -1;
- }
- }
- }
-
- rc = wrap_execvp (file, (char *const *) argv);
-
- free (argv);
-
-/* return rc;
- * }
- */
diff --git a/guts/vfork.c b/guts/vfork.c
deleted file mode 100644
index 4e0f767..0000000
--- a/guts/vfork.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2008-2010 Wind River Systems; see
- * guts/COPYRIGHT for information.
- *
- * static int
- * wrap_vfork(void) {
- * int rc = -1;
- */
-
- /* like fakeroot, we really can't handle vfork's implications */
- rc = real_fork();
- if (rc == 0)
- pseudo_client_reset();
-
-/* return rc;
- * }
- */