Hook execvpe(), a GNU extension.

This commit is contained in:
Simon Ruderich
2013-06-10 17:10:44 +02:00
parent 55e8d0d38a
commit 237251ae9c
4 changed files with 53 additions and 0 deletions

View File

@@ -19,6 +19,9 @@
#include <config.h>
/* For execvpe(). */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -269,6 +272,35 @@ int main(int argc unused, char **argv) {
execvp(argv[0], args);
return EXIT_FAILURE;
#ifdef HAVE_EXECVPE
/* execvpe(3), but not testing the p(ath) part */
} else if (!skip--) {
char *args[] = { argv0, NULL };
char *envp[] = { "TEST=54", ldpreload, NULL };
execvpe(argv[0], args, envp);
return EXIT_FAILURE;
} else if (!skip--) {
char *args[] = { argv0, "foo", "bar", NULL };
char *envp[] = { "TEST=55", ldpreload, NULL };
execvpe(argv[0], args, envp);
return EXIT_FAILURE;
#else
/* Fake output to let the test pass. */
} else if (!skip--) {
puts("argv[0] = |./example_exec|");
puts("environ[0] = |TEST=54|");
puts("environ[2] = |COLORED_STDERR_FDS=2,|");
puts("");
puts("argv[0] = |./example_exec|");
puts("argv[1] = |foo|");
puts("argv[2] = |bar|");
puts("environ[0] = |TEST=55|");
puts("environ[2] = |COLORED_STDERR_FDS=2,|");
puts("");
#endif
}
printf("Done.\n");

View File

@@ -101,4 +101,14 @@ environ[0] = |TEST=53|
environ[1] = |FOO=|
environ[3] = |COLORED_STDERR_FDS=2,|
argv[0] = |./example_exec|
environ[0] = |TEST=54|
environ[2] = |COLORED_STDERR_FDS=2,|
argv[0] = |./example_exec|
argv[1] = |foo|
argv[2] = |bar|
environ[0] = |TEST=55|
environ[2] = |COLORED_STDERR_FDS=2,|
Done.