Module Name:    src
Committed By:   kre
Date:           Sun Mar 19 17:55:57 UTC 2023

Modified Files:
        src/bin/sh: error.c exec.c

Log Message:
Do a better job handling EACCES errors from exec() calls.   If the
EACCES is from the namei(), treat it just like ENOENT or ENOTDIR
(and if that is the final error, the exit status from a failed exec
will be 127).   If the EACCES is from the exec() itself, that indicates
the file to be run exists, but has no 'x' permission.   That's a
meaningful error (as distinct from just "yet another PATH element
search failure").

While here, return the first meaingful error we encountered while
searching PATH, rather than the last (and ENOENT if there are none
of those).

This change results in some failed command executions returning status
127 now, where they returned 126 before - which better reflects the
intent of those values (127 is simply "not found" whereas 126 is "found
but couldn't be executed").

We still do nothing to distinguish errors encountered looking up the
command name give, with errors encountered (by the kernel) attempting to
run an interpreter needed for the exec to succeed (#! line path, or
/libexec/ld.elf_so and similar - or anything else of a similar nature).


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/bin/sh/error.c
cvs rdiff -u -r1.57 -r1.58 src/bin/sh/exec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Reply via email to