CONFIG_FEATURE_SH_STANDALONE_SHELL is sometimes forced in busybox-1.4.1?

Denis Vlasenko vda.linux at googlemail.com
Thu Mar 1 14:01:28 PST 2007


On Thursday 01 March 2007 14:23, Natanael Copa wrote:
> Hi,
> 
> I have an interesting bug/feature reported by a user.
> 
> I run a linux/uclibc/busybox distro and I have provided native packages
> like coreutils iproute2 as a packages that you can install if you need
> the GNU stuff.
> 
> So I have the SH_STANDALONE_SHELL disabled to allow $PATH rule over
> busybox internals. 
> 
> # CONFIG_FEATURE_SH_STANDALONE_SHELL is not set
> 
> In most cases this seems to work just fine. Install a package and the
> native verison will be used.
> 
> Now a user just reported that when coreutils is installed the busybox
> version of 'cat' is always used, unless he write the full path /bin/cat.
> 
> I verified and its true. So I checked more applets. Many applets will
> just run the native version but a few will always run the busybox
> applet. the complete list:
> 
> bin/cat
> bin/chmod
> bin/chown
> bin/cp
> bin/cut
> bin/dd
> bin/echo (is ok since I have said to ash to use internal echo)
> bin/false
> bin/ln
> bin/ls
> bin/mkdir
> bin/pwd
> bin/rm
> bin/sort
> bin/touch
> bin/true

Obviously, it is caused by this in ash.c:

static int is_safe_applet(char *name)
{
        /* It isn't a bug to have non-existent applet here... */
        /* ...just a waste of space... */
        static const char safe_applets[][8] = {
                "["
                USE_AWK    (, "awk"    )
                USE_CAT    (, "cat"    )
                USE_CHMOD  (, "chmod"  )
                USE_CHOWN  (, "chown"  )
                USE_CP     (, "cp"     )
                USE_CUT    (, "cut"    )
                USE_DD     (, "dd"     )
                USE_ECHO   (, "echo"   )
                USE_FIND   (, "find"   )
                USE_HEXDUMP(, "hexdump")
                USE_LN     (, "ln"     )
                USE_LS     (, "ls"     )
                USE_MKDIR  (, "mkdir"  )
                USE_RM     (, "rm"     )
                USE_SORT   (, "sort"   )
                USE_TEST   (, "test"   )
                USE_TOUCH  (, "touch"  )
                USE_XARGS  (, "xargs"  )
        };
        int n = sizeof(safe_applets) / sizeof(safe_applets[0]);
        int i;
        for (i = 0; i < n; i++)
                if (strcmp(safe_applets[i], name) == 0)
                        return 1;

        return 0;
}

I propose making "safe applets" usage dependent on
FEATURE_SH_STANDALONE_SHELL too.

[ What is "safe applet":
"safe applets" are not exec'ed. we just call their
<applet>_main() ]
--
vda


More information about the busybox mailing list