[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1005972: sourced functions when run from set -e shells are suprising



Package: initramfs-tools
Version: 0.140
Severity: minor

Dear Maintainer,

Half of the initramfs-tools hook scripts on my system use "set -e"[0].
However if /usr/share/initramfs-tools/scripts/functions is sourced it
does not handle errors correctly when called from a "set -e" shell, for
example the function "configure_networking" runs ipconfig and if it
times out it will exit non-zero. S the "for ROUNDTTT" loop does not
complete, further ipconfig invocations are not attempted and the calling
hook script exists before completion.

The hook scripts on my system (fsck, resume and xfs) that call
scripts/functions don't use "set -e". However some scripts in the
archive do call configure_networking from a "set -e" shell, eg aoe[2].

I ran into this when writing a new custom hook script for clevis and was
surprised by the current behaviour. I think all functions that are
sourced should be audited to handle "set -e" and all initramfs-tools
eventually modified to use "set -e".

Kind Regards
Tom

-- mkinitramfs hooks
/etc/initramfs-tools/hooks/:

/usr/share/initramfs-tools/hooks:
amd64_microcode
btrfs
cryptgnupg
cryptgnupg-sc
cryptkeyctl
cryptopensc
cryptpassdev
cryptroot
cryptroot-unlock
dmsetup
fsck
fuse
intel_microcode
keymap
klibc-utils
kmod
lvm2
mdadm
ntfs_3g
plymouth
reiserfsprogs
resume
thermal
thin-provisioning-tools
udev
xfs
zz-busybox

[0]
$ head -10 /usr/share/initramfs-tools/hooks/* | egrep "^=|-e"
==> /usr/share/initramfs-tools/hooks/amd64_microcode <==
==> /usr/share/initramfs-tools/hooks/btrfs <==
set -e
==> /usr/share/initramfs-tools/hooks/cryptgnupg <==
set -e
==> /usr/share/initramfs-tools/hooks/cryptgnupg-sc <==
set -e
==> /usr/share/initramfs-tools/hooks/cryptkeyctl <==
set -e
==> /usr/share/initramfs-tools/hooks/cryptopensc <==
set -e
==> /usr/share/initramfs-tools/hooks/cryptpassdev <==
set -e
==> /usr/share/initramfs-tools/hooks/cryptroot <==
==> /usr/share/initramfs-tools/hooks/cryptroot-unlock <==
==> /usr/share/initramfs-tools/hooks/dmsetup <==
==> /usr/share/initramfs-tools/hooks/fsck <==
==> /usr/share/initramfs-tools/hooks/fuse <==
set -e
==> /usr/share/initramfs-tools/hooks/intel_microcode <==
==> /usr/share/initramfs-tools/hooks/keymap <==
==> /usr/share/initramfs-tools/hooks/klibc-utils <==
==> /usr/share/initramfs-tools/hooks/kmod <==
#!/bin/sh -e
==> /usr/share/initramfs-tools/hooks/lvm2 <==
==> /usr/share/initramfs-tools/hooks/mdadm <==
set -eu
==> /usr/share/initramfs-tools/hooks/ntfs_3g <==
set -e
==> /usr/share/initramfs-tools/hooks/plymouth <==
set -e
==> /usr/share/initramfs-tools/hooks/reiserfsprogs <==
==> /usr/share/initramfs-tools/hooks/resume <==
==> /usr/share/initramfs-tools/hooks/thermal <==
==> /usr/share/initramfs-tools/hooks/thin-provisioning-tools <==
==> /usr/share/initramfs-tools/hooks/udev <==
#!/bin/sh -e
==> /usr/share/initramfs-tools/hooks/xfs <==
==> /usr/share/initramfs-tools/hooks/zz-busybox <==
set -e

[1] https://sources.debian.org/src/initramfs-tools/0.140/scripts/functions/?hl=236#L315
[2] https://sources.debian.org/src/aoetools/36-5/debian/local-top_aoe/


Reply to: