dracut/0030-fix-squash-lib-harden-against-empty-initdir.patch
Pavel Valena a3b408b277 Upgrade to dracut 103
- enable dracut-cpio binary
- feat(fips-crypto-policies): make c-p follow FIPS mode automatically
- fix(fips-crypto-policies): make it depend on fips dracut module

Resolves: RHEL-59678,RHEL-65204

From-source-git-commit: ff3186be9d5871c6ec216019463199bb78cc1b32
2024-11-01 18:42:50 +01:00

41 lines
1.3 KiB
Diff

From e391c64afd187a81861301c949db5ffd1f9a3e5d Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Mon, 26 Aug 2024 15:29:01 +0200
Subject: [PATCH 30/32] fix(squash-lib): harden against empty $initdir
The postinstall phase of 99squash-lib has the potential to delete the
whole rootfs if $initdir is empty. This should(tm) never happen.
Nevertheless as the consequences are so devastating it is better to
double check.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
(cherry picked from commit 6b089c70761c81a7b82a1bfba5f2c1faef7e972f)
Resolves: RHEL-43460
---
modules.d/99squash-lib/module-setup.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/modules.d/99squash-lib/module-setup.sh b/modules.d/99squash-lib/module-setup.sh
index 6a0b6f85..be3d3dc0 100755
--- a/modules.d/99squash-lib/module-setup.sh
+++ b/modules.d/99squash-lib/module-setup.sh
@@ -72,6 +72,14 @@ squash_install() {
squash_installpost() {
local _file _handler
+ # this shouldn't happen but...
+ # ...better safe than deleting your rootfs
+ if [[ -z $initdir ]]; then
+ #shellcheck disable=SC2016
+ dfatal '$initdir not set. Something went terribly wrong.'
+ exit 1
+ fi
+
_handler=$(squash_get_handler)
[[ -n $_handler ]] || return 1
--
2.42.0