From a93d86689d85015b5bf465ab0ef810449bb55d41 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 22 Apr 2016 11:48:16 +0100 Subject: ash: adjustment to 'busybox' command in standalone shell mode A previous change allowed the command 'busybox' (which isn't an applet) to be invoked by a direct call to the executable, avoiding a PATH lookup. For some reason I also checked that the name of the executable was 'busybox.exe'. This seems unnecessary and prevents the trick from working when the binary is called 'sh.exe', so don't do it any more. --- shell/ash.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 878c76da4..52feff422 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7767,15 +7767,6 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char ** } } -#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE -/* check if command and executable are both busybox */ -static int busybox_cmd_and_exe(const char *name) -{ - return strcmp(name, "busybox") == 0 && - strcmp(bb_basename(bb_busybox_exec_path), "busybox.exe") == 0; -} -#endif - /* * Exec a program. Never returns. If you change this routine, you may * have to change the find_command routine as well. @@ -7807,8 +7798,9 @@ shellexec(char **argv, const char *path, int idx) } e = errno; #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE - } else if (busybox_cmd_and_exe(argv[0])) { + } else if (strcmp(argv[0], "busybox") == 0) { tryexec(-1, bb_busybox_exec_path, argv, envp); + e = errno; #endif } else { try_PATH: @@ -12778,14 +12770,6 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) return; } -#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE - if (busybox_cmd_and_exe(name)) { - entry->u.index = -1; - entry->cmdtype = CMDNORMAL; - return; - } -#endif - /* #if ENABLE_FEATURE_SH_STANDALONE... moved after builtin check */ updatetbl = (path == pathval()); @@ -12839,7 +12823,9 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) #if ENABLE_FEATURE_SH_STANDALONE { int applet_no = find_applet_by_name(name); - if (applet_no >= 0) { + if (applet_no >= 0 || + /* requires find_applet_by_name to return -1 on no match */ + (ENABLE_PLATFORM_MINGW32 && strcmp(name, "busybox") == 0)) { entry->cmdtype = CMDNORMAL; entry->u.index = -2 - applet_no; return; -- cgit v1.2.3-55-g6feb