diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-04 15:34:33 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-04 15:34:33 +0000 |
commit | aacf801b253e1e608ab46a4ccee87e943734742e (patch) | |
tree | 102071563ba8a6e5c449d87a2a76c7fa3adc7e31 | |
parent | 2bea24120ba728153a6bf94a5fed0f226e8bf438 (diff) | |
download | busybox-w32-aacf801b253e1e608ab46a4ccee87e943734742e.tar.gz busybox-w32-aacf801b253e1e608ab46a4ccee87e943734742e.tar.bz2 busybox-w32-aacf801b253e1e608ab46a4ccee87e943734742e.zip |
ash: fix a couple of test cases
The ash tests exitcode_EACCES and exitcode_ENOENT both failed.
In commit 92dbd3c09 a test was added to tryexec to check that
the file being run existed and was executable. The error codes
returned by this test were incorrect.
The slightly later commit f5783ef14 added a similar test in
spawnveq which got the error codes right.
Remove the test from tryexec and some superfluous error messages
from spawnveq.
-rw-r--r-- | shell/ash.c | 14 | ||||
-rw-r--r-- | win32/process.c | 4 |
2 files changed, 5 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c index 4c23286c1..510a86cab 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -8387,10 +8387,6 @@ static int builtinloc = -1; /* index in path of %builtin, or -1 */ | |||
8387 | static void | 8387 | static void |
8388 | tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, char **envp) | 8388 | tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, char **envp) |
8389 | { | 8389 | { |
8390 | #if ENABLE_PLATFORM_MINGW32 | ||
8391 | char *new_cmd; | ||
8392 | #endif | ||
8393 | |||
8394 | #if ENABLE_FEATURE_SH_STANDALONE | 8390 | #if ENABLE_FEATURE_SH_STANDALONE |
8395 | if (applet_no >= 0) { | 8391 | if (applet_no >= 0) { |
8396 | if (APPLET_IS_NOEXEC(applet_no)) { | 8392 | if (APPLET_IS_NOEXEC(applet_no)) { |
@@ -8408,13 +8404,11 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c | |||
8408 | #endif | 8404 | #endif |
8409 | 8405 | ||
8410 | #if ENABLE_PLATFORM_MINGW32 | 8406 | #if ENABLE_PLATFORM_MINGW32 |
8411 | /* ensure we have a path to a real, executable file */ | 8407 | { |
8412 | if (!(new_cmd=add_win32_extension(cmd)) && !file_is_executable(cmd)) { | 8408 | char *new_cmd = add_win32_extension(cmd); |
8413 | errno = EACCES; | 8409 | execve(new_cmd ? new_cmd : cmd, argv, envp); |
8414 | return; | 8410 | free(new_cmd); |
8415 | } | 8411 | } |
8416 | execve(new_cmd ? new_cmd : cmd, argv, envp); | ||
8417 | free(new_cmd); | ||
8418 | /* skip POSIX-mandated retry on ENOEXEC */ | 8412 | /* skip POSIX-mandated retry on ENOEXEC */ |
8419 | #else | 8413 | #else |
8420 | repeat: | 8414 | repeat: |
diff --git a/win32/process.c b/win32/process.c index 1c409a20e..e9b34b56d 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -216,12 +216,10 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) | |||
216 | if (stat(path, &st) == 0) { | 216 | if (stat(path, &st) == 0) { |
217 | if (!S_ISREG(st.st_mode) || !(st.st_mode&S_IXUSR)) { | 217 | if (!S_ISREG(st.st_mode) || !(st.st_mode&S_IXUSR)) { |
218 | errno = EACCES; | 218 | errno = EACCES; |
219 | goto error; | 219 | return -1; |
220 | } | 220 | } |
221 | } | 221 | } |
222 | else { | 222 | else { |
223 | error: | ||
224 | fprintf(stderr, "spawnveq: %s: %s\n", path, strerror(errno)); | ||
225 | return -1; | 223 | return -1; |
226 | } | 224 | } |
227 | 225 | ||