Skip to content

Commit

Permalink
fix(shutdown): be robust against forced shutdown
Browse files Browse the repository at this point in the history
When a forced shutdown is issued through sending a burst of Ctrl-Alt-Del
keys, systemd sends SIGTERM to all processes. This ends up killing
dracut-initramfs-restore as well, preventing the script from detecting
that the unpack of the initramfs is incomplete, which later causes a
crash to happen when "shutdown" tries to execute from the unpacked
initramfs.

This fix makes sure dracut-initramfs-restore remains alive to detect
the unpack failed (because cpio was killed by systemd too).

Refs:
 * https://bugzilla.redhat.com/show_bug.cgi?id=2023665
  • Loading branch information
rmetrich authored and johannbg committed Nov 16, 2021
1 parent 3f56d48 commit b9ba3c8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dracut-initramfs-restore.sh
Expand Up @@ -6,6 +6,11 @@ set -e
[ -e /run/initramfs/bin/sh ] && exit 0
[ -e /run/initramfs/.need_shutdown ] || exit 0

# SIGTERM signal is received upon forced shutdown: ignore the signal
# We want to remain alive to be able to trap unpacking errors to avoid
# switching root to an incompletely unpacked initramfs
trap 'echo "Received SIGTERM signal, ignoring!" >&2' TERM

KERNEL_VERSION="$(uname -r)"

[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
Expand Down

0 comments on commit b9ba3c8

Please sign in to comment.