From 6ea8bad476ee406f580e103f915a55839db7fcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Sun, 22 Mar 2026 17:50:13 +0100 Subject: [PATCH] Fix false negative of clevis detection in initramfs --- autodecrypt.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autodecrypt.sh b/autodecrypt.sh index 223317e..48e1cc6 100755 --- a/autodecrypt.sh +++ b/autodecrypt.sh @@ -153,6 +153,7 @@ function test_clevis_unlock { } function check_initramfs_hooks { + local clevis_found=0 echo "Checking initramfs hooks..." if [ ! -f "/usr/share/initramfs-tools/hooks/clevis" ]; then @@ -161,7 +162,11 @@ function check_initramfs_hooks { fi # Check if clevis hook is in the generated initramfs - if ! lsinitramfs /boot/initrd.img-$(uname -r) 2>/dev/null | grep -q clevis; then + set +o pipefail + # if grep finds a match, lsinitramfs gets SIGPIPE but we still want a success + lsinitramfs /boot/initrd.img-$(uname -r) 2>/dev/null | grep -q clevis && clevis_found=1 + set -o pipefail + if [ "$clevis_found" = 0 ]; then echo "WARNING: Clevis not found in current initramfs. Will update initramfs." return 1 fi