[PATCH] Ash doesn't add env variables for sub-apps in nofork mode

Denys Vlasenko vda.linux at googlemail.com
Mon Oct 20 08:17:14 UTC 2008


On Thursday 16 October 2008 12:46:11 am Ian Wienand wrote:
> Environment variables don't get set for sub-applications when ash is
> built in standalone mode.
> 
> For example, build ls colors in as default, start up busybox ash and
> run
> 
> $ export LS_COLORS=none
> $ ls
> 
> and you can see the colors still come out (we found the issue with
> TZ).
> 
> The problem is that the sub-application is calling getenv(), but the
> variable has never been set in the shell environment.

Thanks for the report.

> Suggested patch below.  This doesn't fix the 'LS_COLORS=none ls' case,
> but makes 'export' work as expected.

This one does, and is also much less intrusive:

diff -d -urpN busybox.9/shell/ash.c busybox.a/shell/ash.c
--- busybox.9/shell/ash.c       2008-10-07 11:17:30.000000000 +0200
+++ busybox.a/shell/ash.c       2008-10-20 10:10:23.000000000 +0200
@@ -7008,8 +7008,11 @@ tryexec(USE_FEATURE_SH_STANDALONE(int ap

 #if ENABLE_FEATURE_SH_STANDALONE
        if (applet_no >= 0) {
-               if (APPLET_IS_NOEXEC(applet_no))
+               if (APPLET_IS_NOEXEC(applet_no)) {
+                       while (*envp)
+                               putenv(*envp++);
                        run_applet_no_and_exit(applet_no, argv);
+               }
                /* re-exec ourselves with the new arguments */
                execve(bb_busybox_exec_path, argv, envp);
                /* If they called chroot or otherwise made the binary no longer



Fixed in svn. Thanks.
--
vda



More information about the busybox mailing list