diff options
| author | Ron Yorston <rmy@pobox.com> | 2023-03-23 11:29:34 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2023-03-23 11:29:34 +0000 |
| commit | f491e57d1ce04ec8124b9605268e5ecd3b1fb489 (patch) | |
| tree | 9b1c096fe44b8f52f26920b583a7d50e0afde785 /miscutils | |
| parent | 138e956a2e34d1b708366b6286687766a7176341 (diff) | |
| download | busybox-w32-f491e57d1ce04ec8124b9605268e5ecd3b1fb489.tar.gz busybox-w32-f491e57d1ce04ec8124b9605268e5ecd3b1fb489.tar.bz2 busybox-w32-f491e57d1ce04ec8124b9605268e5ecd3b1fb489.zip | |
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.
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/drop.c | 26 |
1 files changed, 18 insertions, 8 deletions
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 @@ | |||
| 16 | //config:config CDROP | 16 | //config:config CDROP |
| 17 | //config: bool "cdrop" | 17 | //config: bool "cdrop" |
| 18 | //config: default y | 18 | //config: default y |
| 19 | //config: depends on PLATFORM_MINGW32 && SH_IS_ASH | 19 | //config: depends on PLATFORM_MINGW32 |
| 20 | //config: help | 20 | //config: help |
| 21 | //config: Run a command without elevated privileges using cmd.exe | 21 | //config: Run a command without elevated privileges using cmd.exe |
| 22 | 22 | ||
| 23 | //config:config PDROP | 23 | //config:config PDROP |
| 24 | //config: bool "pdrop" | 24 | //config: bool "pdrop" |
| 25 | //config: default y | 25 | //config: default y |
| 26 | //config: depends on PLATFORM_MINGW32 && SH_IS_ASH | 26 | //config: depends on PLATFORM_MINGW32 |
| 27 | //config: help | 27 | //config: help |
| 28 | //config: Run a command without elevated privileges using PowerShell | 28 | //config: Run a command without elevated privileges using PowerShell |
| 29 | 29 | ||
| @@ -56,6 +56,7 @@ | |||
| 56 | #include "libbb.h" | 56 | #include "libbb.h" |
| 57 | #include <winsafer.h> | 57 | #include <winsafer.h> |
| 58 | #include <lazyload.h> | 58 | #include <lazyload.h> |
| 59 | #include "NUM_APPLETS.h" | ||
| 59 | 60 | ||
| 60 | int drop_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 61 | int drop_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 61 | int drop_main(int argc, char **argv) | 62 | int drop_main(int argc, char **argv) |
| @@ -101,26 +102,35 @@ int drop_main(int argc, char **argv) | |||
| 101 | 102 | ||
| 102 | if (argc == 1 || strcmp(argv[1], "-c") == 0 | 103 | if (argc == 1 || strcmp(argv[1], "-c") == 0 |
| 103 | IF_CDROP(|| strcmp(argv[1], "/c") == 0)) { | 104 | IF_CDROP(|| strcmp(argv[1], "/c") == 0)) { |
| 105 | switch (*applet_name) { | ||
| 104 | #if ENABLE_PDROP | 106 | #if ENABLE_PDROP |
| 105 | if (*applet_name == 'p') { | 107 | case 'p': |
| 106 | arg = "powershell.exe"; | 108 | arg = "powershell.exe"; |
| 107 | exe = find_first_executable(arg); | 109 | exe = find_first_executable(arg); |
| 108 | } else | 110 | break; |
| 109 | #endif | 111 | #endif |
| 110 | #if ENABLE_CDROP | 112 | #if ENABLE_CDROP |
| 111 | if (*applet_name == 'c') { | 113 | case 'c': |
| 112 | arg = "cmd.exe"; | 114 | arg = "cmd.exe"; |
| 113 | exe = find_first_executable(arg); | 115 | exe = find_first_executable(arg); |
| 114 | } else | 116 | break; |
| 115 | #endif | 117 | #endif |
| 116 | { | 118 | #if ENABLE_DROP |
| 119 | case 'd': | ||
| 117 | arg = "sh"; | 120 | arg = "sh"; |
| 118 | exe = xstrdup(bb_busybox_exec_path); | 121 | exe = xstrdup(bb_busybox_exec_path); |
| 122 | break; | ||
| 123 | #endif | ||
| 124 | default: | ||
| 125 | // Never executed, just to silence warnings. | ||
| 126 | arg = argv[0]; | ||
| 127 | exe = NULL; | ||
| 128 | break; | ||
| 119 | } | 129 | } |
| 120 | } else { | 130 | } else { |
| 121 | arg = *a++; | 131 | arg = *a++; |
| 122 | 132 | ||
| 123 | #if ENABLE_FEATURE_PREFER_APPLETS | 133 | #if ENABLE_FEATURE_PREFER_APPLETS && NUM_APPLETS > 1 |
| 124 | if (!has_path(arg) && find_applet_by_name(arg) >= 0) { | 134 | if (!has_path(arg) && find_applet_by_name(arg) >= 0) { |
| 125 | exe = xstrdup(bb_busybox_exec_path); | 135 | exe = xstrdup(bb_busybox_exec_path); |
| 126 | } else | 136 | } else |
