dracut/modules.d/99base
Renaud Métrich 22a80629b4 fix(dracut): be more robust when using 'set -u'
From bash manpage, FUNCNAME exists only inside functions. When in debug
mode, make sure to use an empty default value as FUNCNAME[0] when
outside of functions.

With bash4 this wasn't an issue, but is with bash5 with hardening option
'set -u' used, as shown in the example below:

Incorrect:

$ bash -u -c 'echo -n ${FUNCNAME[0]}'
bash: line 1: FUNCNAME[0]: unbound variable
$

Correct:

$ bash -u -c 'echo -n ${FUNCNAME[0]-}'
$

This hardening enables sourcing dracut-lib.sh from external utilities
executing in the initramfs such as clevis-luks-askpass, which uses
hardening option 'set -u' internally.
(see Clevis PR https://github.com/latchset/clevis/pull/340)

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
2022-02-04 12:24:22 +00:00
..
dracut-dev-lib.sh fix(base): add missing `str_replace` to `dracut-dev-lib.sh` 2021-05-18 11:31:16 +02:00
dracut-lib.sh fix(dracut): be more robust when using 'set -u' 2022-02-04 12:24:22 +00:00
init.sh fix(base): do not quote $initargs for switch_root 2021-08-06 13:52:19 +00:00
initqueue.sh fix(base): shellcheck for modules.d/99base 2021-03-26 12:17:00 +01:00
loginit.sh fix(base): shellcheck for modules.d/99base 2021-03-26 12:17:00 +01:00
module-setup.sh fix(base): tr needs to be installed 2021-08-25 23:58:12 +00:00
parse-root-opts.sh fix(base): shellcheck for modules.d/99base 2021-03-26 12:17:00 +01:00
rdsosreport.sh fix(base): shellcheck for modules.d/99base 2021-03-26 12:17:00 +01:00