From f491e57d1ce04ec8124b9605268e5ecd3b1fb489 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 23 Mar 2023 11:29:34 +0000 Subject: drop: cdrop and pdrop don't need shell The cdrop and pdrop variants don't require the binary to include a shell. Removing this dependency makes it possible to build cdrop/pdrop as a much smaller standalone binaries. Update the default configuration to build a standalone make binary to exclude drop/cdrop/pdrop. --- configs/make32_defconfig | 12 ++++++++++-- configs/make64_defconfig | 12 ++++++++++-- miscutils/drop.c | 26 ++++++++++++++++++-------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/configs/make32_defconfig b/configs/make32_defconfig index 2c5c15ba9..354c2eb87 100644 --- a/configs/make32_defconfig +++ b/configs/make32_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Busybox version: 1.36.0.git -# Thu Nov 10 11:18:15 2022 +# Busybox version: 1.37.0.git +# Thu Mar 23 11:11:07 2023 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -145,6 +145,9 @@ CONFIG_LAST_SUPPORTED_WCHAR=0 # CONFIG_UNICODE_BIDI_SUPPORT is not set # CONFIG_UNICODE_NEUTRAL_TABLE is not set # CONFIG_UNICODE_PRESERVE_BROKEN is not set +# CONFIG_LOOP_CONFIGURE is not set +# CONFIG_NO_LOOP_CONFIGURE is not set +CONFIG_TRY_LOOP_CONFIGURE=y # # Applets @@ -784,6 +787,9 @@ CONFIG_FEATURE_CROND_DIR="" # CONFIG_DEVFSD_VERBOSE is not set # CONFIG_FEATURE_DEVFS is not set # CONFIG_DEVMEM is not set +# CONFIG_DROP is not set +# CONFIG_CDROP is not set +# CONFIG_PDROP is not set # CONFIG_FBSPLASH is not set # CONFIG_FLASH_ERASEALL is not set # CONFIG_FLASH_LOCK is not set @@ -1015,6 +1021,7 @@ CONFIG_DHCPD_LEASES_FILE="" # CONFIG_FEATURE_UDHCPC_ARPING is not set # CONFIG_FEATURE_UDHCPC_SANITIZEOPT is not set CONFIG_UDHCPC_DEFAULT_SCRIPT="" +CONFIG_UDHCPC6_DEFAULT_SCRIPT="" # CONFIG_UDHCPC6 is not set # CONFIG_FEATURE_UDHCPC6_RFC3646 is not set # CONFIG_FEATURE_UDHCPC6_RFC4704 is not set @@ -1151,6 +1158,7 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_ASH_NOCONSOLE=y CONFIG_ASH_NOCASEGLOB=y +CONFIG_ASH_IGNORE_CR=y # CONFIG_CTTYHACK is not set # CONFIG_HUSH is not set # CONFIG_SHELL_HUSH is not set diff --git a/configs/make64_defconfig b/configs/make64_defconfig index 5fa5c4ebc..6564603c8 100644 --- a/configs/make64_defconfig +++ b/configs/make64_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Busybox version: 1.36.0.git -# Thu Nov 10 11:18:15 2022 +# Busybox version: 1.37.0.git +# Thu Mar 23 11:13:36 2023 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -145,6 +145,9 @@ CONFIG_LAST_SUPPORTED_WCHAR=0 # CONFIG_UNICODE_BIDI_SUPPORT is not set # CONFIG_UNICODE_NEUTRAL_TABLE is not set # CONFIG_UNICODE_PRESERVE_BROKEN is not set +# CONFIG_LOOP_CONFIGURE is not set +# CONFIG_NO_LOOP_CONFIGURE is not set +CONFIG_TRY_LOOP_CONFIGURE=y # # Applets @@ -784,6 +787,9 @@ CONFIG_FEATURE_CROND_DIR="" # CONFIG_DEVFSD_VERBOSE is not set # CONFIG_FEATURE_DEVFS is not set # CONFIG_DEVMEM is not set +# CONFIG_DROP is not set +# CONFIG_CDROP is not set +# CONFIG_PDROP is not set # CONFIG_FBSPLASH is not set # CONFIG_FLASH_ERASEALL is not set # CONFIG_FLASH_LOCK is not set @@ -1015,6 +1021,7 @@ CONFIG_DHCPD_LEASES_FILE="" # CONFIG_FEATURE_UDHCPC_ARPING is not set # CONFIG_FEATURE_UDHCPC_SANITIZEOPT is not set CONFIG_UDHCPC_DEFAULT_SCRIPT="" +CONFIG_UDHCPC6_DEFAULT_SCRIPT="" # CONFIG_UDHCPC6 is not set # CONFIG_FEATURE_UDHCPC6_RFC3646 is not set # CONFIG_FEATURE_UDHCPC6_RFC4704 is not set @@ -1151,6 +1158,7 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_ASH_NOCONSOLE=y CONFIG_ASH_NOCASEGLOB=y +CONFIG_ASH_IGNORE_CR=y # CONFIG_CTTYHACK is not set # CONFIG_HUSH is not set # CONFIG_SHELL_HUSH is not set diff --git a/miscutils/drop.c b/miscutils/drop.c index 9ebee3f04..6effc1831 100644 --- a/miscutils/drop.c +++ b/miscutils/drop.c @@ -16,14 +16,14 @@ //config:config CDROP //config: bool "cdrop" //config: default y -//config: depends on PLATFORM_MINGW32 && SH_IS_ASH +//config: depends on PLATFORM_MINGW32 //config: help //config: Run a command without elevated privileges using cmd.exe //config:config PDROP //config: bool "pdrop" //config: default y -//config: depends on PLATFORM_MINGW32 && SH_IS_ASH +//config: depends on PLATFORM_MINGW32 //config: help //config: Run a command without elevated privileges using PowerShell @@ -56,6 +56,7 @@ #include "libbb.h" #include #include +#include "NUM_APPLETS.h" int drop_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int drop_main(int argc, char **argv) @@ -101,26 +102,35 @@ int drop_main(int argc, char **argv) if (argc == 1 || strcmp(argv[1], "-c") == 0 IF_CDROP(|| strcmp(argv[1], "/c") == 0)) { + switch (*applet_name) { #if ENABLE_PDROP - if (*applet_name == 'p') { + case 'p': arg = "powershell.exe"; exe = find_first_executable(arg); - } else + break; #endif #if ENABLE_CDROP - if (*applet_name == 'c') { + case 'c': arg = "cmd.exe"; exe = find_first_executable(arg); - } else + break; #endif - { +#if ENABLE_DROP + case 'd': arg = "sh"; exe = xstrdup(bb_busybox_exec_path); + break; +#endif + default: + // Never executed, just to silence warnings. + arg = argv[0]; + exe = NULL; + break; } } else { arg = *a++; -#if ENABLE_FEATURE_PREFER_APPLETS +#if ENABLE_FEATURE_PREFER_APPLETS && NUM_APPLETS > 1 if (!has_path(arg) && find_applet_by_name(arg) >= 0) { exe = xstrdup(bb_busybox_exec_path); } else -- cgit v1.2.3-55-g6feb