[PATCH] execlp, execvp, execvpe: Don't fall back to sh on ENOEXEC.
Carlos O'Donell
carlos@redhat.com
Tue Dec 15 22:17:25 GMT 2020
On 12/15/20 4:04 PM, Zack Weinberg wrote:
> On Tue, Dec 15, 2020 at 3:46 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>> On 12/15/20 8:05 AM, Zack Weinberg wrote:
>>> When direct execution of a program fails with ENOEXEC, do not attempt
>>> to run that program as if it were a shell script.
>>
>> A less-intrusive approach would be for execlp etc.'s fallback to look at the
>> first 1024 bytes (or whatever) of the file and fail with ENOEXEC if it finds
>> a NUL byte, before trying to exec /bin/sh on the file.
>
> That's a clever idea for preserving compatibility, but to do it we
> would have to open and read the file, which could easily cause
> problems due to e.g. lack of free file descriptor space. If we can't
> remove this code altogether I'm not sure it's worth changing anything
> in libc.
>
> POSIX recommends that the *shell* implement a similar heuristic, and
> it appears bash already does.
What shell were you using that didn't implement this?
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list