Skip to content

Commit b9ba3c8

Browse files
rmetrichjohannbg
authored andcommitted
fix(shutdown): be robust against forced shutdown
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
1 parent 3f56d48 commit b9ba3c8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

dracut-initramfs-restore.sh

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ set -e
66
[ -e /run/initramfs/bin/sh ] && exit 0
77
[ -e /run/initramfs/.need_shutdown ] || exit 0
88

9+
# SIGTERM signal is received upon forced shutdown: ignore the signal
10+
# We want to remain alive to be able to trap unpacking errors to avoid
11+
# switching root to an incompletely unpacked initramfs
12+
trap 'echo "Received SIGTERM signal, ignoring!" >&2' TERM
13+
914
KERNEL_VERSION="$(uname -r)"
1015

1116
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut

0 commit comments

Comments
 (0)