diff options
author | Ron Yorston <rmy@pobox.com> | 2023-12-09 09:43:06 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-12-09 09:43:06 +0000 |
commit | 6bb25c4493268d24a3b82d3268b2adf624de88bd (patch) | |
tree | c68887dd2e818685192b5496e3e676944008af57 | |
parent | 7dff7f37600209353cf4e86d1cca29bacf5f7372 (diff) | |
download | busybox-w32-6bb25c4493268d24a3b82d3268b2adf624de88bd.tar.gz busybox-w32-6bb25c4493268d24a3b82d3268b2adf624de88bd.tar.bz2 busybox-w32-6bb25c4493268d24a3b82d3268b2adf624de88bd.zip |
win32: allow hardcoded list of applets to override
The environment variable BB_OVERRIDE_APPLETS provides control over
which applets are preferred in standalone shell mode. Allow a
similar list to be hardcoded in the binary with the OVERRIDE_APPLETS
configuration string.
The environment variable is checked first. If it doesn't override
the applet the hardcoded string is then checked too.
The default for OVERRIDE_APPLETS is an empty string. In this case
the size and behaviour of the binary is unchanged.
-rw-r--r-- | Config.in | 10 | ||||
-rw-r--r-- | configs/mingw32_defconfig | 3 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 3 | ||||
-rw-r--r-- | configs/mingw64u_defconfig | 3 | ||||
-rw-r--r-- | libbb/appletlib.c | 13 |
5 files changed, 26 insertions, 6 deletions
@@ -556,6 +556,16 @@ config FEATURE_EXTRA_FILE_DATA | |||
556 | determine the ownership of files so that, for example, 'ls' can | 556 | determine the ownership of files so that, for example, 'ls' can |
557 | distinguish files belonging to the current user. | 557 | distinguish files belonging to the current user. |
558 | 558 | ||
559 | config OVERRIDE_APPLETS | ||
560 | string "Override applets" | ||
561 | default "" | ||
562 | depends on PLATFORM_MINGW32 && (FEATURE_PREFER_APPLETS || FEATURE_SH_STANDALONE) | ||
563 | help | ||
564 | A list of applets to be ignored in standalone shell mode. The | ||
565 | format is the same as that used by the BB_OVERRIDE_APPLETS | ||
566 | environment variable. BB_OVERRIDE_APPLETS is checked first, if it | ||
567 | allows the applet and this list is non-empty it is checked too. | ||
568 | |||
559 | comment 'Build Options' | 569 | comment 'Build Options' |
560 | 570 | ||
561 | config STATIC | 571 | config STATIC |
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 3a21dfae6..ee01330d1 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.37.0.git | 3 | # Busybox version: 1.37.0.git |
4 | # Wed Sep 20 08:30:38 2023 | 4 | # Sat Dec 9 09:38:58 2023 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -61,6 +61,7 @@ CONFIG_FEATURE_EURO=y | |||
61 | CONFIG_TERMINAL_MODE=5 | 61 | CONFIG_TERMINAL_MODE=5 |
62 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y | 62 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y |
63 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 63 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
64 | CONFIG_OVERRIDE_APPLETS="" | ||
64 | 65 | ||
65 | # | 66 | # |
66 | # Build Options | 67 | # Build Options |
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 8b993460f..3fed1c99b 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.37.0.git | 3 | # Busybox version: 1.37.0.git |
4 | # Wed Sep 20 08:30:38 2023 | 4 | # Sat Dec 9 09:38:58 2023 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -61,6 +61,7 @@ CONFIG_FEATURE_EURO=y | |||
61 | CONFIG_TERMINAL_MODE=5 | 61 | CONFIG_TERMINAL_MODE=5 |
62 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y | 62 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y |
63 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 63 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
64 | CONFIG_OVERRIDE_APPLETS="" | ||
64 | 65 | ||
65 | # | 66 | # |
66 | # Build Options | 67 | # Build Options |
diff --git a/configs/mingw64u_defconfig b/configs/mingw64u_defconfig index a7428d1d2..f3391a206 100644 --- a/configs/mingw64u_defconfig +++ b/configs/mingw64u_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.37.0.git | 3 | # Busybox version: 1.37.0.git |
4 | # Wed Sep 20 08:30:38 2023 | 4 | # Sat Dec 9 09:38:58 2023 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -61,6 +61,7 @@ CONFIG_FEATURE_UTF8_OUTPUT=y | |||
61 | CONFIG_TERMINAL_MODE=5 | 61 | CONFIG_TERMINAL_MODE=5 |
62 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y | 62 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y |
63 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 63 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
64 | CONFIG_OVERRIDE_APPLETS="" | ||
64 | 65 | ||
65 | # | 66 | # |
66 | # Build Options | 67 | # Build Options |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 6b610743a..3c9cebf1e 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -282,12 +282,11 @@ static int external_exists(const char *name) | |||
282 | return ret != NULL; | 282 | return ret != NULL; |
283 | } | 283 | } |
284 | 284 | ||
285 | int FAST_FUNC is_applet_preferred(const char *name) | 285 | static int is_applet_preferred_by_var(const char *name, const char *var) |
286 | { | 286 | { |
287 | const char *var, *s, *sep; | 287 | const char *s, *sep; |
288 | size_t len; | 288 | size_t len; |
289 | 289 | ||
290 | var = getenv(BB_OVERRIDE_APPLETS); | ||
291 | if (var && *var) { | 290 | if (var && *var) { |
292 | /* '-' disables all applets */ | 291 | /* '-' disables all applets */ |
293 | if (var[0] == '-' && var[1] == '\0') | 292 | if (var[0] == '-' && var[1] == '\0') |
@@ -319,6 +318,14 @@ int FAST_FUNC is_applet_preferred(const char *name) | |||
319 | } | 318 | } |
320 | return TRUE; | 319 | return TRUE; |
321 | } | 320 | } |
321 | |||
322 | int FAST_FUNC is_applet_preferred(const char *name) | ||
323 | { | ||
324 | int ret = is_applet_preferred_by_var(name, getenv(BB_OVERRIDE_APPLETS)); | ||
325 | if (sizeof(CONFIG_OVERRIDE_APPLETS) > 1 && ret) | ||
326 | ret = is_applet_preferred_by_var(name, CONFIG_OVERRIDE_APPLETS); | ||
327 | return ret; | ||
328 | } | ||
322 | #endif | 329 | #endif |
323 | 330 | ||
324 | 331 | ||