aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-08-13 14:27:56 +0100
committerRon Yorston <rmy@pobox.com>2020-08-13 14:58:01 +0100
commit41ef232fc522d91f29931ea4ee547432ca8899ee (patch)
treed2acfdc43839b68b569debb4494d5c7fbd8bc66b /debianutils
parent16e5930a65f3c7c570b8a0dda8daa19ab4792fa2 (diff)
downloadbusybox-w32-41ef232fc522d91f29931ea4ee547432ca8899ee.tar.gz
busybox-w32-41ef232fc522d91f29931ea4ee547432ca8899ee.tar.bz2
busybox-w32-41ef232fc522d91f29931ea4ee547432ca8899ee.zip
win32: use built-in applets for non-existent binaries with Unix-style paths
Shell scripts moved from Unix may contain hard-coded paths to binaries such as /bin/sh. A recent commit made it possible to execute such binaries reliably, but that does require them to be installed. As an alternative solution: if a binary with a standard Unix path prefix can't be found but is available as a built-in applet, run the applet. Add the function unix_path() to detect paths starting with /bin, /usr/bin, /sbin or /usr/sbin. Use this function in: - the 'which' applet - shellexec(), describe_command() and find_command() in ash - mingw_spawn_1() See GitHub issue #195.
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/which.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/debianutils/which.c b/debianutils/which.c
index c8e99acda..384e2cfec 100644
--- a/debianutils/which.c
+++ b/debianutils/which.c
@@ -71,6 +71,10 @@ int which_main(int argc UNUSED_PARAM, char **argv)
71 if (strchr(*argv, '/')) { 71 if (strchr(*argv, '/')) {
72#else 72#else
73 if (has_path(*argv)) { 73 if (has_path(*argv)) {
74# if ENABLE_FEATURE_SH_STANDALONE
75 const char *name = bb_basename(*argv);
76 int is_unix_path = unix_path(*argv);
77# endif
74 *argv = auto_add_system_drive(*argv); 78 *argv = auto_add_system_drive(*argv);
75 if ((p=auto_win32_extension(*argv)) != NULL) { 79 if ((p=auto_win32_extension(*argv)) != NULL) {
76 missing = 0; 80 missing = 0;
@@ -86,6 +90,12 @@ int which_main(int argc UNUSED_PARAM, char **argv)
86 puts(*argv); 90 puts(*argv);
87#endif 91#endif
88 } 92 }
93#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE
94 else if (is_unix_path && find_applet_by_name(name) >= 0) {
95 missing = 0;
96 puts(name);
97 }
98#endif
89 } else { 99 } else {
90 char *path; 100 char *path;
91#if !ENABLE_PLATFORM_MINGW32 101#if !ENABLE_PLATFORM_MINGW32