Blame 0002-systemd-account-for-unlocking-failures-in-clevis-luk.patch

93af905
From 2a16458622be983aba3762079d7a72383bd8be02 Mon Sep 17 00:00:00 2001
93af905
From: Sergio Correia <scorreia@redhat.com>
93af905
Date: Fri, 29 Oct 2021 10:58:26 -0300
93af905
Subject: [PATCH 2/2] systemd: account for unlocking failures in
93af905
 clevis-luks-askpass
93af905
93af905
As unlock may fail for some reason, e.g. the network is not up yet,
93af905
one way cause problems would be to add extra `rd.luks.uuid' params
93af905
to the cmdline, which would then cause such devices to be unlocked
93af905
in early boot. If the unlocking fail, those devices might not be
93af905
accounted for in the clevis_devices_to_unlock() check, as it is
93af905
based on crypttab.
93af905
93af905
Let's make sure there are no pending ask.* sockets waiting to be
93af905
answered, before exiting.
93af905
93af905
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1878892
93af905
---
93af905
 src/luks/systemd/clevis-luks-askpass.in | 5 ++++-
93af905
 1 file changed, 4 insertions(+), 1 deletion(-)
93af905
93af905
diff --git a/src/luks/systemd/clevis-luks-askpass.in b/src/luks/systemd/clevis-luks-askpass.in
93af905
index 8f54859..a6699c9 100755
93af905
--- a/src/luks/systemd/clevis-luks-askpass.in
93af905
+++ b/src/luks/systemd/clevis-luks-askpass.in
93af905
@@ -67,8 +67,11 @@ while true; do
93af905
     done
93af905
 
93af905
     [ "${loop}" != true ] && break
93af905
+
93af905
     # Checking for pending devices to be unlocked.
93af905
-    if remaining=$(clevis_devices_to_unlock) && [ -z "${remaining}" ]; then
93af905
+    remaining_crypttab=$(clevis_devices_to_unlock) ||:
93af905
+    remaining_askfiles=$(ls "${path}"/ask.* 2>/dev/null) ||:
93af905
+    if [ -z "${remaining_crypttab}" ] && [ -z "${remaining_askfiles}" ]; then
93af905
         break;
93af905
     fi
93af905
 
93af905
-- 
93af905
2.33.1
93af905