aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-06-09 16:26:34 +0100
committerRon Yorston <rmy@pobox.com>2020-06-09 16:52:45 +0100
commit32833bc06873f83c786232617b4390b60252c417 (patch)
tree8f175374e2f43538ab65c5b5b550cd10d71bc0de
parent4fe76647b356a85810fa3d355d7ad0512be1210c (diff)
downloadbusybox-w32-32833bc06873f83c786232617b4390b60252c417.tar.gz
busybox-w32-32833bc06873f83c786232617b4390b60252c417.tar.bz2
busybox-w32-32833bc06873f83c786232617b4390b60252c417.zip
ash: treat all applets as NOEXEC
In standalone shell mode tryexec() treats all applets as NOEXEC. Except for the shell: calling ash_main() recursively seems unwise. This avoids creating a new process for the applet (which is a Good Thing on Microsoft Windows where creating processes is expensive) but leaves the resources used by the invoking shell in the current process.
-rw-r--r--libbb/appletlib.c3
-rw-r--r--shell/ash.c5
2 files changed, 8 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index b2c85905c..9caa04ac3 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -1122,6 +1122,9 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar
1122# if defined APPLET_NO_false 1122# if defined APPLET_NO_false
1123 && applet_no != APPLET_NO_false 1123 && applet_no != APPLET_NO_false
1124# endif 1124# endif
1125# if defined APPLET_NO_busybox
1126 && applet_no != APPLET_NO_busybox
1127# endif
1125 ) { 1128 ) {
1126 if (argc == 2 && strcmp(argv[1], "--help") == 0) { 1129 if (argc == 2 && strcmp(argv[1], "--help") == 0) {
1127 /* Make "foo --help" exit with 0: */ 1130 /* Make "foo --help" exit with 0: */
diff --git a/shell/ash.c b/shell/ash.c
index e21131b01..d76d3f571 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8666,7 +8666,12 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
8666{ 8666{
8667#if ENABLE_FEATURE_SH_STANDALONE 8667#if ENABLE_FEATURE_SH_STANDALONE
8668 if (applet_no >= 0) { 8668 if (applet_no >= 0) {
8669# if ENABLE_PLATFORM_MINGW32
8670 /* Treat all applets as NOEXEC apart from the shell itself */
8671 if (applet_main[applet_no] != ash_main) {
8672# else
8669 if (APPLET_IS_NOEXEC(applet_no)) { 8673 if (APPLET_IS_NOEXEC(applet_no)) {
8674# endif
8670 clearenv(); 8675 clearenv();
8671 while (*envp) 8676 while (*envp)
8672 putenv(*envp++); 8677 putenv(*envp++);