diff options
author | jilles <jilles@FreeBSD.org> | 2011-02-03 23:38:11 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-02-03 23:38:11 +0000 |
commit | 86ccb3f9c0e743f3a8113e4d15ec2434a1920bf4 (patch) | |
tree | 9265e1293e8aff57926abadf894b23eb21636936 /bin | |
parent | 6c509b30f6fbcbe8a525c41dff97e826a989dc25 (diff) | |
download | FreeBSD-src-86ccb3f9c0e743f3a8113e4d15ec2434a1920bf4.zip FreeBSD-src-86ccb3f9c0e743f3a8113e4d15ec2434a1920bf4.tar.gz |
sh: Return only 126 or 127 for execve() failures.
Do not return 2 for errors other than [EACCES] or [ENOENT].
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/exec.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 5d00bcc..2d781ab 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -129,20 +129,13 @@ shellexec(char **argv, char **envp, const char *path, int idx) } /* Map to POSIX errors */ - switch (e) { - case EACCES: - exerrno = 126; - break; - case ENOENT: + if (e == ENOENT || e == ENOTDIR) { exerrno = 127; - break; - default: - exerrno = 2; - break; - } - if (e == ENOENT || e == ENOTDIR) exerror(EXEXEC, "%s: not found", argv[0]); - exerror(EXEXEC, "%s: %s", argv[0], strerror(e)); + } else { + exerrno = 126; + exerror(EXEXEC, "%s: %s", argv[0], strerror(e)); + } } |