[Bug 10346] Default shell missing

bugzilla at busybox.net bugzilla at busybox.net
Thu Oct 5 13:26:59 UTC 2017


https://bugs.busybox.net/show_bug.cgi?id=10346

--- Comment #4 from Andrej Valek <andrej.valek at siemens.com> ---
(In reply to Denys Vlasenko from comment #3)
At first, this issue will occur only on no/suid busybox using with
open-embedded. So I will try explain it with examples.

.config consist:
#
# Shells
#
CONFIG_SH_IS_ASH=y
# CONFIG_SH_IS_HUSH is not set
# CONFIG_SH_IS_NONE is not set
# CONFIG_BASH_IS_ASH is not set
# CONFIG_BASH_IS_HUSH is not set
CONFIG_BASH_IS_NONE=y
CONFIG_ASH=y

So ASH is going to be used like a default shell.

configure + compilation procedure:
make a backup copy of .config
$ cp .config .config.orig

create suid and nosuid configurations
$ make busybox.cfg.suid
list configs in suid
$ cat busybox.cfg.suid
CONFIG_LOGIN
CONFIG_PASSWD
CONFIG_SU
CONFIG_VLOCK
CONFIG_PING
CONFIG_PING6
CONFIG_TRACEROUTE

$ make busybox.cfg.nosuid
$ cat busybox.cfg.nosuid
...
CONFIG_SH_IS_ASH
CONFIG_ASH
...
As you can see, ASH is in nosuid.

# create list of disabled applets
>$ for i in `cat busybox.cfg.suid busybox.cfg.nosuid`; do echo "# $i is not set" >> .config.disable.apps; done
Now are all "is not set" configs in one file ".config.disable.apps"

# merge configurations
$ merge_config.sh -m .config.orig .config.disable.apps

$ cat .config
...
# CONFIG_SH_IS_HUSH is not set
# CONFIG_SH_IS_NONE is not set
# CONFIG_BASH_IS_ASH is not set
# CONFIG_BASH_IS_HUSH is not set
# CONFIG_SH_IS_ASH is not set
# CONFIG_ASH is not set
...
Now ASH is not set, so SH is not set too.

# create a copy of actual .config
$ cp .config .config.nonapps

# loop over items in .config and split them into no/suid
for s in suid nosuid; do
        cat busybox.cfg.$s | while read item; do
                grep -w "$item" .config.orig
        done > .config.app.$s

# continue for suid
$ cat .config.app.suid
CONFIG_LOGIN=y
CONFIG_PASSWD=y
CONFIG_SU=y
CONFIG_VLOCK=y
CONFIG_PING=y
CONFIG_PING6=y
CONFIG_TRACEROUTE=y
So CONFIG_SH_IS_ASH is not mentioned here, what is ok. But CONFIG_SH_IS_NONE=y
is missing.

# merge configurations
$ merge_config.sh -m .config.nonapps .config.app.suid
$ cat .config
...
# CONFIG_SH_IS_HUSH is not set
# CONFIG_SH_IS_NONE is not set
# CONFIG_BASH_IS_ASH is not set
# CONFIG_BASH_IS_HUSH is not set
CONFIG_BASH_IS_NONE=y
# CONFIG_SH_IS_ASH is not set
# CONFIG_ASH is not set
...
So ASH is not set.

# Now build the busybox. So it's seems to be, that ASH is not set, so default
shell is none.
$ make busybox_unstripped
 # generate build files
 - ./scripts/gen_build_files.sh busybox busybox
 - # ! problem is here, create oldconfig
  - make -f Makefile V=1 oldconfig
>*
>* Shells
>*
>Choose which shell is aliased to 'sh' name
>> 1. ash (SH_IS_ASH)
>  2. hush (SH_IS_HUSH)
>  3. none (SH_IS_NONE)
>choice[1-3?]: 1
>Choose which shell is aliased to 'bash' name
>  1. ash (BASH_IS_ASH)
>  2. hush (BASH_IS_HUSH)
>> 3. none (BASH_IS_NONE)
>choice[1-3?]: 3
>!!!! ash (ASH) [N/y/?] n <---- it was selected automatically without dependency checking
>  Optimize for size instead of speed (ASH_OPTIMIZE_FOR_SIZE) [Y/n] y
>  Use internal glob() implementation (ASH_INTERNAL_GLOB) [Y/n/?] y
>  bash-compatible extensions (ASH_BASH_COMPAT) [Y/n] y
>  Job control (ASH_JOB_CONTROL) [Y/n] y
>  Alias support (ASH_ALIAS) [Y/n] y
>  Pseudorandom generator and $RANDOM variable (ASH_RANDOM_SUPPORT) [N/y/?] n
>  Expand prompt string (ASH_EXPAND_PRMT) [Y/n/?] y
>  Idle timeout variable $TMOUT (ASH_IDLE_TIMEOUT) [N/y/?] n
>  Check for new mail in interactive shell (ASH_MAIL) [N/y/?] n
>  echo builtin (ASH_ECHO) [Y/n] y
>  printf builtin (ASH_PRINTF) [Y/n] y
>  test builtin (ASH_TEST) [Y/n] y
>  help builtin (ASH_HELP) [Y/n] y
>  getopts builtin (ASH_GETOPTS) [Y/n] y
>  command builtin (ASH_CMDCMD) [Y/n/?] y
... continue in building process
$ mv busybox_unstripped busybox.suid

$ make busybox.links
# list created links
$ cat busybox.links.suid
/bin/ping
/bin/ping6
/bin/login
/bin/mount
/usr/bin/passwd
/bin/sh <--- what is wrong
/bin/su
/usr/bin/traceroute
/usr/bin/traceroute6
/usr/bin/vlock


Same process for busybox.nosuid, but SH_IS_ASH was set correctly.
$ cat busybox.links.nosuid
...
/bin/sh
...
So links are on both file, what is wrong. Default shell is not set. It reflect
to, that scripts without shebang could not be run.

Version before the mentioned commit was depending on CONFIG_ASH and if
SH_IS_xxx was not set, the default was SH_IS_NONE=y. It created a link only in
explicit selected shell.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list