aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-09-05 20:24:50 -0400
committerUlrich Drepper <drepper@gmail.com>2011-09-05 20:24:50 -0400
commitd96de9634a334af16c0ac711074c15ac1762b23c (patch)
tree78f566d420a800c92347a7b994d8850a644f1b61 /sysdeps/posix
parent54b1f8b6bf88e34c55b77b2e4acb00776b4a5783 (diff)
downloadglibc-d96de9634a334af16c0ac711074c15ac1762b23c.zip
glibc-d96de9634a334af16c0ac711074c15ac1762b23c.tar.gz
glibc-d96de9634a334af16c0ac711074c15ac1762b23c.tar.bz2
Try shell in posix_spawn* only in compat mode
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/spawni.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index f19862f..129edcd 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -28,6 +28,7 @@
#include "spawn_int.h"
#include <not-cancel.h>
#include <local-setxid.h>
+#include <shlib-compat.h>
/* The Unix standard contains a long explanation of the way to signal
@@ -38,6 +39,7 @@
#define SPAWN_ERROR 127
+#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15)
/* The file is accessible but it is not an executable file. Invoke
the shell to interpret it as a script. */
static void
@@ -64,6 +66,10 @@ script_execute (const char *file, char *const argv[], char *const envp[])
__execve (new_argv[0], new_argv, envp);
}
}
+# define tryshell (xflags & SPAWN_XFLAGS_TRY_SHELL)
+#else
+# define tryshell 0
+#endif
/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
@@ -72,7 +78,7 @@ int
__spawni (pid_t *pid, const char *file,
const posix_spawn_file_actions_t *file_actions,
const posix_spawnattr_t *attrp, char *const argv[],
- char *const envp[], int use_path)
+ char *const envp[], int xflags)
{
pid_t new_pid;
char *path, *p, *name;
@@ -226,12 +232,12 @@ __spawni (pid_t *pid, const char *file,
}
}
- if (! use_path || strchr (file, '/') != NULL)
+ if ((xflags & SPAWN_XFLAGS_USE_PATH) == 0 || strchr (file, '/') != NULL)
{
/* The FILE parameter is actually a path. */
__execve (file, argv, envp);
- if (errno == ENOEXEC)
+ if (tryshell && errno == ENOEXEC)
script_execute (file, argv, envp);
/* Oh, oh. `execve' returns. This is bad. */
@@ -277,7 +283,7 @@ __spawni (pid_t *pid, const char *file,
/* Try to execute this name. If it works, execv will not return. */
__execve (startp, argv, envp);
- if (errno == ENOEXEC)
+ if (tryshell && errno == ENOEXEC)
script_execute (startp, argv, envp);
switch (errno)