From 32833bc06873f83c786232617b4390b60252c417 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 9 Jun 2020 16:26:34 +0100 Subject: 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. --- shell/ash.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'shell') 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 { #if ENABLE_FEATURE_SH_STANDALONE if (applet_no >= 0) { +# if ENABLE_PLATFORM_MINGW32 + /* Treat all applets as NOEXEC apart from the shell itself */ + if (applet_main[applet_no] != ash_main) { +# else if (APPLET_IS_NOEXEC(applet_no)) { +# endif clearenv(); while (*envp) putenv(*envp++); -- cgit v1.2.3-55-g6feb