Package: dracut
Version: 048+80-1
Severity: important

Dear Maintainer,

When generating an initrd with bash 5.0-2 installed, the generated initrd
fails to boot with the error message:

> /lib/fs-lib.sh: line 109: _drv=e2fsck fsck_drv_com

The behaviour of "local" declared variables in POSIX mode seems to have
changed, which does no longer allow them to be overwritten by eval. This
is only the case if bash is executed as /bin/sh. Since "local" is not a
part of POSIX, I consider this to be dracut's fault and not bash's.

I wrote a small shell script (a reduced version of fs-lib.sh) to
demonstrates the problem:

#!/bin/sh
fsck_drv_com() {
        echo "issuing $_drv"
        _out=$($_drv)
}
fsck_single() {
        local _drv="_drv=true fsck_drv_com"
        eval "$_drv"
}
fsck_single

This works with /bin/bash as interpreter, also with /bin/sh linked to
dash, and it used to work with bash 4.4.18-3.1. It also produces the
correct output without the "local" keyword:

> issuing true

When /bin/sh is a link to bash 5.0-2 the script fails with the following
output:

> issuing _drv=true fsck_drv_com
> /tmp/bash-error.sh: line 5: _drv=true: command not found

I can currently think of three options:

- either dracut has to be rewritten to be fully POSIX-compliant

- dracut has to rely on a shell, that guarantees to enhance POSIX with
  the local keyword

- dracut has to make sure /init is executed by /bin/bash when
  /bin/sh is a symlink to bash.

The 3rd option could be easily accomplished by adding the following line
to the top of /init (/usr/lib/dracut/modules.d/99base/init.sh) after the
initial comment block:

[ -f /bin/bash ] && [ "$BASH" = "/bin/sh" ] && exec /bin/bash /init

Ingo

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (800, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.18-echse20190126 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages dracut depends on:
ii  dracut-core  048+80-1

dracut recommends no packages.

Versions of packages dracut suggests:
pn  dracut-network  <none>

-- no debconf information

Reply via email to