diff options
author | Ron Yorston <rmy@pobox.com> | 2022-05-06 08:26:55 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-05-06 09:30:43 +0100 |
commit | 26ba73098e714459e3294679228a1d54eed14799 (patch) | |
tree | 5e5dda2adbf6577276baf372626465213fd2f1b9 /win32/mingw.c | |
parent | 3b5042430fc4b82d44e0430f9ecc21a9228d1651 (diff) | |
download | busybox-w32-26ba73098e714459e3294679228a1d54eed14799.tar.gz busybox-w32-26ba73098e714459e3294679228a1d54eed14799.tar.bz2 busybox-w32-26ba73098e714459e3294679228a1d54eed14799.zip |
win32: search PATH for missing Unix-style executables
Commit 41ef232fc5 (win32: use built-in applets for non-existent
binaries with Unix-style paths) alters what happens when trying
to find an executable. If all of the following apply:
- the pathname starts with one of the standard directories for Unix
executables (/bin, /usr/bin, /sbin, /usr/sbin);
- the file isn't found relative to the system root;
- the basename matches an applet
then the applet is run.
Further extend the procedure so that if the first two conditions are
met and either:
- the PREFER_APPLETS and SH_STANDALONE features are enabled and the
basename *doesn't* match an applet
or
- the PREFER_APPLETS and SH_STANDALONE features are disabled
then PATH is searched for the basename.
This affects:
- how interpreters and binaries are spawned by mingw_spawn_interpreter()
and mingw_spawnvp();
- how 'which' and the shell search for binaries.
Special steps need to be taken in the shell to avoid treating shell
built-ins and functions as applets.
As a consequence of this change:
- An executable that isn't an applet, say curl.exe, can be run as
/usr/bin/curl so long as it's in a directory in PATH. It doesn't
have to be in C:/usr/bin.
- If the PREFER_APPLETS and SH_STANDALONE features are disabled binaries
can be run using paths referring to standard Unix directories even if
they're installed elsewhere in PATH.
Diffstat (limited to 'win32/mingw.c')
-rw-r--r-- | win32/mingw.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 0fa2a1b8f..d6b725e17 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2096,7 +2096,6 @@ void *get_proc_addr(const char *dll, const char *function, | |||
2096 | return proc->pfunction; | 2096 | return proc->pfunction; |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | #if ENABLE_FEATURE_SH_STANDALONE || ENABLE_FEATURE_PREFER_APPLETS | ||
2100 | int unix_path(const char *path) | 2099 | int unix_path(const char *path) |
2101 | { | 2100 | { |
2102 | int i; | 2101 | int i; |
@@ -2107,7 +2106,6 @@ int unix_path(const char *path) | |||
2107 | free(p); | 2106 | free(p); |
2108 | return i >= 0; | 2107 | return i >= 0; |
2109 | } | 2108 | } |
2110 | #endif | ||
2111 | 2109 | ||
2112 | /* Return true if file is referenced using a path. This means a path | 2110 | /* Return true if file is referenced using a path. This means a path |
2113 | * look-up isn't required. */ | 2111 | * look-up isn't required. */ |