From 9ff1d43bc406a3ced93aa0e36191a34518df7203 Mon Sep 17 00:00:00 2001 From: Sergio Correia Date: Tue, 4 Jan 2022 07:59:44 -0300 Subject: [PATCH] Enable debugging in clevis scripts when rd.debug is set Resolves: rhbz#2022420 --- ...gging-in-clevis-scripts-when-rd.debu.patch | 45 +++++++++++++++++++ clevis.spec | 7 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 0003-luks-enable-debugging-in-clevis-scripts-when-rd.debu.patch diff --git a/0003-luks-enable-debugging-in-clevis-scripts-when-rd.debu.patch b/0003-luks-enable-debugging-in-clevis-scripts-when-rd.debu.patch new file mode 100644 index 0000000..63ced6c --- /dev/null +++ b/0003-luks-enable-debugging-in-clevis-scripts-when-rd.debu.patch @@ -0,0 +1,45 @@ +From 6a238d8a774953e8832b5795ef2d9ba1ba8e6c28 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Renaud=20M=C3=A9trich?= + <1163635+rmetrich@users.noreply.github.com> +Date: Wed, 1 Dec 2021 09:37:35 -0300 +Subject: [PATCH 3/3] luks: enable debugging in clevis scripts when rd.debug is + set (#340) + +On Fedora/RHEL, the rd.debug kernel command line parameter controls +debugging. +By implementing the functionality inside clevis, troubleshooting will be +greatly eased. +See RHBZ #1980742 (https://bugzilla.redhat.com/show_bug.cgi?id=1980742). +--- + src/luks/clevis-luks-common-functions.in | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/src/luks/clevis-luks-common-functions.in b/src/luks/clevis-luks-common-functions.in +index a80639c..d53d2ab 100644 +--- a/src/luks/clevis-luks-common-functions.in ++++ b/src/luks/clevis-luks-common-functions.in +@@ -20,6 +20,21 @@ + + CLEVIS_UUID="cb6e8904-81ff-40da-a84a-07ab9ab5715e" + ++enable_debugging() { ++ # Automatically enable debugging if in initramfs phase and rd.debug ++ if [ -e /usr/lib/dracut-lib.sh ]; then ++ local bashopts=$- ++ # Because dracut is loosely written, disable hardening options temporarily ++ [[ $bashopts != *u* ]] || set +u ++ [[ $bashopts != *e* ]] || set +e ++ . /usr/lib/dracut-lib.sh ++ [[ $bashopts != *u* ]] || set -u ++ [[ $bashopts != *e* ]] || set -e ++ fi ++} ++ ++enable_debugging ++ + # valid_slot() will check whether a given slot is possibly valid, i.e., if it + # is a numeric value within the specified range. + valid_slot() { +-- +2.33.1 + diff --git a/clevis.spec b/clevis.spec index cf9ef41..b83435a 100644 --- a/clevis.spec +++ b/clevis.spec @@ -1,6 +1,6 @@ Name: clevis Version: 18 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Automated decryption framework License: GPLv3+ @@ -10,6 +10,7 @@ Source1: clevis.sysusers Patch0001: 0001-sss-use-BN_set_word-x-0-instead-of-BN_zero.patch Patch0002: 0002-systemd-account-for-unlocking-failures-in-clevis-luk.patch +Patch0003: 0003-luks-enable-debugging-in-clevis-scripts-when-rd.debu.patch BuildRequires: git-core BuildRequires: gcc @@ -194,6 +195,10 @@ exit 0 %attr(4755, root, root) %{_libexecdir}/%{name}-luks-udisks2 %changelog +* Tue Jan 04 2022 Sergio Correia - 18-6 +- Enable debugging in clevis scripts when rd.debug is set + Resolves: rhbz#2022420 + * Wed Nov 17 2021 Sergio Correia - 18-5 - Account for unlocking failures in clevis-luks-askpass Resolves: rhbz#2022421