aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-04-22 11:48:16 +0100
committerRon Yorston <rmy@pobox.com>2016-04-22 13:13:53 +0100
commita93d86689d85015b5bf465ab0ef810449bb55d41 (patch)
tree962f1a53eb2594b9f77f5d3af1fe9ad3dff4ee76
parent98b290e9b8221b7d7ffbf47da1e8ecce62a75369 (diff)
downloadbusybox-w32-a93d86689d85015b5bf465ab0ef810449bb55d41.tar.gz
busybox-w32-a93d86689d85015b5bf465ab0ef810449bb55d41.tar.bz2
busybox-w32-a93d86689d85015b5bf465ab0ef810449bb55d41.zip
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.
-rw-r--r--shell/ash.c24
1 files 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 **
7767 } 7767 }
7768} 7768}
7769 7769
7770#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE
7771/* check if command and executable are both busybox */
7772static int busybox_cmd_and_exe(const char *name)
7773{
7774 return strcmp(name, "busybox") == 0 &&
7775 strcmp(bb_basename(bb_busybox_exec_path), "busybox.exe") == 0;
7776}
7777#endif
7778
7779/* 7770/*
7780 * Exec a program. Never returns. If you change this routine, you may 7771 * Exec a program. Never returns. If you change this routine, you may
7781 * have to change the find_command routine as well. 7772 * have to change the find_command routine as well.
@@ -7807,8 +7798,9 @@ shellexec(char **argv, const char *path, int idx)
7807 } 7798 }
7808 e = errno; 7799 e = errno;
7809#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE 7800#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE
7810 } else if (busybox_cmd_and_exe(argv[0])) { 7801 } else if (strcmp(argv[0], "busybox") == 0) {
7811 tryexec(-1, bb_busybox_exec_path, argv, envp); 7802 tryexec(-1, bb_busybox_exec_path, argv, envp);
7803 e = errno;
7812#endif 7804#endif
7813 } else { 7805 } else {
7814 try_PATH: 7806 try_PATH:
@@ -12778,14 +12770,6 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
12778 return; 12770 return;
12779 } 12771 }
12780 12772
12781#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE
12782 if (busybox_cmd_and_exe(name)) {
12783 entry->u.index = -1;
12784 entry->cmdtype = CMDNORMAL;
12785 return;
12786 }
12787#endif
12788
12789/* #if ENABLE_FEATURE_SH_STANDALONE... moved after builtin check */ 12773/* #if ENABLE_FEATURE_SH_STANDALONE... moved after builtin check */
12790 12774
12791 updatetbl = (path == pathval()); 12775 updatetbl = (path == pathval());
@@ -12839,7 +12823,9 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
12839#if ENABLE_FEATURE_SH_STANDALONE 12823#if ENABLE_FEATURE_SH_STANDALONE
12840 { 12824 {
12841 int applet_no = find_applet_by_name(name); 12825 int applet_no = find_applet_by_name(name);
12842 if (applet_no >= 0) { 12826 if (applet_no >= 0 ||
12827 /* requires find_applet_by_name to return -1 on no match */
12828 (ENABLE_PLATFORM_MINGW32 && strcmp(name, "busybox") == 0)) {
12843 entry->cmdtype = CMDNORMAL; 12829 entry->cmdtype = CMDNORMAL;
12844 entry->u.index = -2 - applet_no; 12830 entry->u.index = -2 - applet_no;
12845 return; 12831 return;