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

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