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.
+2020-12-23 Bruno Haible <bruno@clisp.org>
+
+ 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.
+
2020-12-23 Bruno Haible <bruno@clisp.org>
posix_spawn[p]: Fix compilation error on Windows (regr. 2020-12-14).
Date Modules Changes
+2020-12-23 execute These functions no longer execute scripts without
+ spawn-pipe '#!' marker through /bin/sh. To execute such a
+ posix_spawn script as a shell script, either add a '#!/bin/sh'
+ posix_spawnp marker in the first line, or specify "/bin/sh" as
+ the program to execute and the script as its first
+ argument.
+
2020-12-18 free This module, obsoleted in 2008, is gone.
2020-12-14 findprog-in The function 'find_in_given_path' now takes a 3rd
exitcode = spawnpvech (P_WAIT, prog_path, argv + 1,
(const char * const *) environ, directory,
stdin_handle, stdout_handle, stderr_handle);
+# if 0 /* Executing arbitrary files as shell scripts is unsecure. */
if (exitcode == -1 && errno == ENOEXEC)
{
/* prog is not a native executable. Try to execute it as a
(const char * const *) environ, directory,
stdin_handle, stdout_handle, stderr_handle);
}
+# endif
}
if (exitcode == -1)
saved_errno = errno;
child = spawnpvech (P_NOWAIT, prog_path, argv + 1,
(const char * const *) environ, directory,
stdin_handle, stdout_handle, stderr_handle);
+# if 0 /* Executing arbitrary files as shell scripts is unsecure. */
if (child == -1 && errno == ENOEXEC)
{
/* prog is not a native executable. Try to execute it as a
(const char * const *) environ, directory,
stdin_handle, stdout_handle, stderr_handle);
}
+# endif
}
failed:
if (child == -1)
{
child = _spawnvpe (P_NOWAIT, prog_path, argv + 1,
(const char **) environ);
+# if 0 /* Executing arbitrary files as shell scripts is unsecure. */
if (child == -1 && errno == ENOEXEC)
{
/* prog is not a native executable. Try to execute it as a
child = _spawnvpe (P_NOWAIT, argv[0], argv,
(const char **) environ);
}
+# endif
}
if (child == -1)
saved_errno = errno;
# define sigprocmask __sigprocmask
# define strchrnul __strchrnul
# define vfork __vfork
-#else
-# undef internal_function
-# define internal_function /* empty */
#endif
#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
/* 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);
}
/* 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: