Blame SOURCES/clevis-7-subshell.patch

d77600
From 7d19c76bfc9a7b569a1077d1e5673a28bf31606f Mon Sep 17 00:00:00 2001
d77600
From: Javier Martinez Canillas <javierm@redhat.com>
d77600
Date: Tue, 6 Mar 2018 13:59:34 +0100
d77600
Subject: [PATCH] Don't execute clevis-luks-unlock while loop in a subshell
d77600
d77600
The loop that tries to open the dm-crypt devices using the pins in the
d77600
luksmeta header is executed in a subshell. So on success it calls exit
d77600
to exit the subshell.
d77600
d77600
But then clevis-luks-unlock has no way to know if the encrypted device
d77600
was opened correctly or not. So run the loop in the main shell process
d77600
and return 0 as exit status if the operation was successful.
d77600
d77600
Fixes: #36
d77600
d77600
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
d77600
---
d77600
 src/clevis-luks-unlock | 4 ++--
d77600
 1 file changed, 2 insertions(+), 2 deletions(-)
d77600
d77600
diff --git a/src/clevis-luks-unlock b/src/clevis-luks-unlock
d77600
index 6396680..7d316cd 100755
d77600
--- a/src/clevis-luks-unlock
d77600
+++ b/src/clevis-luks-unlock
d77600
@@ -54,7 +54,7 @@ fi
d77600
 
d77600
 NAME=${NAME:-luks-`cryptsetup luksUUID $DEV`}
d77600
 
d77600
-luksmeta show -d "$DEV" | while read -r slot state uuid; do
d77600
+while read -r slot state uuid; do
d77600
     [ "$state" != "active" ] && continue
d77600
     [ "$uuid" != "$UUID" ] && continue
d77600
 
d77600
@@ -62,6 +62,6 @@ luksmeta show -d "$DEV" | while read -r slot state uuid; do
d77600
         echo -n "$pt" | cryptsetup open -d- "$DEV" "$NAME"
d77600
         exit 0
d77600
     fi
d77600
-done
d77600
+done <<< "$(luksmeta show -d "$DEV")"
d77600
 
d77600
 exit 1
d77600
-- 
d77600
2.17.1
d77600