|
|
b3cd9f |
From 876196e809f4ffac055737921cfe273d8399b6e4 Mon Sep 17 00:00:00 2001
|
|
|
b3cd9f |
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
|
|
b3cd9f |
Date: Tue, 16 Nov 2021 11:15:52 +0100
|
|
|
b3cd9f |
Subject: [PATCH] fix(shutdown): be robust against forced shutdown
|
|
|
b3cd9f |
|
|
|
b3cd9f |
When a forced shutdown is issued through sending a burst of Ctrl-Alt-Del
|
|
|
b3cd9f |
keys, systemd sends SIGTERM to all processes. This ends up killing
|
|
|
b3cd9f |
dracut-initramfs-restore as well, preventing the script from detecting
|
|
|
b3cd9f |
that the unpack of the initramfs is incomplete, which later causes a
|
|
|
b3cd9f |
crash to happen when "shutdown" tries to execute from the unpacked
|
|
|
b3cd9f |
initramfs.
|
|
|
b3cd9f |
|
|
|
b3cd9f |
This fix makes sure dracut-initramfs-restore remains alive to detect
|
|
|
b3cd9f |
the unpack failed (because cpio was killed by systemd too).
|
|
|
b3cd9f |
|
|
|
b3cd9f |
Resolves: rhbz#2023665
|
|
|
b3cd9f |
---
|
|
|
b3cd9f |
dracut-initramfs-restore.sh | 5 +++++
|
|
|
b3cd9f |
1 file changed, 5 insertions(+)
|
|
|
b3cd9f |
|
|
|
b3cd9f |
diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh
|
|
|
b3cd9f |
index 74a952c4..708f98d7 100644
|
|
|
b3cd9f |
--- a/dracut-initramfs-restore.sh
|
|
|
b3cd9f |
+++ b/dracut-initramfs-restore.sh
|
|
|
b3cd9f |
@@ -6,6 +6,11 @@ set -e
|
|
|
b3cd9f |
[ -e /run/initramfs/bin/sh ] && exit 0
|
|
|
b3cd9f |
[ -e /run/initramfs/.need_shutdown ] || exit 0
|
|
|
b3cd9f |
|
|
|
b3cd9f |
+# SIGTERM signal is received upon forced shutdown: ignore the signal
|
|
|
b3cd9f |
+# We want to remain alive to be able to trap unpacking errors to avoid
|
|
|
b3cd9f |
+# switching root to an incompletely unpacked initramfs
|
|
|
b3cd9f |
+trap 'echo "Received SIGTERM signal, ignoring!" >&2' TERM
|
|
|
b3cd9f |
+
|
|
|
b3cd9f |
KERNEL_VERSION="$(uname -r)"
|
|
|
b3cd9f |
|
|
|
b3cd9f |
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
|
|
b3cd9f |
|