Blame SOURCES/0006-luks-enable-debugging-in-clevis-scripts-when-rd.debu.patch

4ba90c
From af10e0fb8cb63d9c3a429b7efa293fe2fe0e2767 Mon Sep 17 00:00:00 2001
4ba90c
From: =?UTF-8?q?Renaud=20M=C3=A9trich?=
4ba90c
 <1163635+rmetrich@users.noreply.github.com>
4ba90c
Date: Wed, 1 Dec 2021 09:37:35 -0300
4ba90c
Subject: [PATCH 6/6] luks: enable debugging in clevis scripts when rd.debug is
4ba90c
 set (#340)
4ba90c
4ba90c
On Fedora/RHEL, the rd.debug kernel command line parameter controls
4ba90c
debugging.
4ba90c
By implementing the functionality inside clevis, troubleshooting will be
4ba90c
greatly eased.
4ba90c
See RHBZ #1980742 (https://bugzilla.redhat.com/show_bug.cgi?id=1980742).
4ba90c
---
4ba90c
 src/luks/clevis-luks-common-functions | 15 +++++++++++++++
4ba90c
 1 file changed, 15 insertions(+)
4ba90c
4ba90c
diff --git a/src/luks/clevis-luks-common-functions b/src/luks/clevis-luks-common-functions
4ba90c
index df8e16d..67ece72 100644
4ba90c
--- a/src/luks/clevis-luks-common-functions
4ba90c
+++ b/src/luks/clevis-luks-common-functions
4ba90c
@@ -20,6 +20,21 @@
4ba90c
 
4ba90c
 CLEVIS_UUID="cb6e8904-81ff-40da-a84a-07ab9ab5715e"
4ba90c
 
4ba90c
+enable_debugging() {
4ba90c
+    # Automatically enable debugging if in initramfs phase and rd.debug
4ba90c
+    if [ -e /usr/lib/dracut-lib.sh ]; then
4ba90c
+        local bashopts=$-
4ba90c
+        # Because dracut is loosely written, disable hardening options temporarily
4ba90c
+        [[ $bashopts != *u* ]] || set +u
4ba90c
+        [[ $bashopts != *e* ]] || set +e
4ba90c
+        . /usr/lib/dracut-lib.sh
4ba90c
+        [[ $bashopts != *u* ]] || set -u
4ba90c
+        [[ $bashopts != *e* ]] || set -e
4ba90c
+    fi
4ba90c
+}
4ba90c
+
4ba90c
+enable_debugging
4ba90c
+
4ba90c
 # valid_slot() will check whether a given slot is possibly valid, i.e., if it
4ba90c
 # is a numeric value within the specified range.
4ba90c
 valid_slot() {
4ba90c
-- 
4ba90c
2.33.1
4ba90c