summaryrefslogtreecommitdiff
path: root/lib/spawni.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-12-23 23:58:17 +0100
committerBruno Haible <bruno@clisp.org>2020-12-24 05:31:53 +0100
commit9042e0456ac72d9333e2d48970c7f2835acfbf79 (patch)
treebac35fc104ba749c8e734950c336e7dee1644369 /lib/spawni.c
parent7fb61502d5a61ad73a3990a214b29d522245c4bc (diff)
downloadgnulib-9042e0456ac72d9333e2d48970c7f2835acfbf79.tar.gz
Don't execute scripts without '#!' marker through /bin/sh.
This reflects the change done in glibc through <https://sourceware.org/bugzilla/show_bug.cgi?id=13134> and <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d96de9634a334af16c0ac711074c15ac1762b23c>. * lib/spawni.c (internal_function): Remove macro. (script_execute): Remove function. (__spawni): Don't invoke script_execute. * lib/execute.c (execute): Disable the ENOEXEC handling. * lib/spawn-pipe.c (create_pipe): Likewise. * NEWS: Mention the change.
Diffstat (limited to 'lib/spawni.c')
-rw-r--r--lib/spawni.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/lib/spawni.c b/lib/spawni.c
index 06d98b473d..182d13ff24 100644
--- a/lib/spawni.c
+++ b/lib/spawni.c
@@ -75,9 +75,6 @@
# define sigprocmask __sigprocmask
# define strchrnul __strchrnul
# define vfork __vfork
-#else
-# undef internal_function
-# define internal_function /* empty */
#endif
@@ -105,36 +102,6 @@ __spawni (pid_t *pid, const char *file,
#else
-/* The file is accessible but it is not an executable file. Invoke
- the shell to interpret it as a script. */
-static void
-internal_function
-script_execute (const char *file, const char *const argv[],
- const char *const envp[])
-{
- /* Count the arguments. */
- int argc = 0;
- while (argv[argc++])
- ;
-
- /* Construct an argument list for the shell. */
- {
- const char **new_argv =
- (const char **) alloca ((argc + 1) * sizeof (const char *));
- new_argv[0] = _PATH_BSHELL;
- new_argv[1] = file;
- while (argc > 1)
- {
- new_argv[argc] = argv[argc - 1];
- --argc;
- }
-
- /* Execute the shell. */
- execve (new_argv[0], (char * const *) new_argv, (char * const *) envp);
- }
-}
-
-
/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
Before running the process perform the actions described in FILE-ACTIONS. */
int
@@ -307,9 +274,6 @@ __spawni (pid_t *pid, const char *file,
/* The FILE parameter is actually a path. */
execve (file, (char * const *) argv, (char * const *) envp);
- if (errno == ENOEXEC)
- script_execute (file, argv, envp);
-
/* Oh, oh. 'execve' returns. This is bad. */
_exit (SPAWN_ERROR);
}
@@ -358,9 +322,6 @@ __spawni (pid_t *pid, const char *file,
/* Try to execute this name. If it works, execv will not return. */
execve (startp, (char * const *) argv, (char * const *) envp);
- if (errno == ENOEXEC)
- script_execute (startp, argv, envp);
-
switch (errno)
{
case EACCES: