Blob Blame History Raw
From 968280e37053bceab47183e5aa9e7bfb34e73d37 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Mon, 13 Jul 2015 10:39:07 +0200
Subject: [PATCH] crypt: skip crypttab entries with the same device

It was only checked, if the name of the crypttab entry matched.
This patch adds checking, if the device matches.
---
 modules.d/90crypt/crypt-lib.sh           | 6 ++++++
 modules.d/90crypt/crypt-run-generator.sh | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules.d/90crypt/crypt-lib.sh b/modules.d/90crypt/crypt-lib.sh
index 213003e..2e13da2 100755
--- a/modules.d/90crypt/crypt-lib.sh
+++ b/modules.d/90crypt/crypt-lib.sh
@@ -5,11 +5,17 @@ command -v getarg >/dev/null || . /lib/dracut-lib.sh
 # check if the crypttab contains an entry for a LUKS UUID
 crypttab_contains() {
     local luks="$1"
+    local dev="$2"
     local l d rest
     if [ -f /etc/crypttab ]; then
         while read l d rest || [ -n "$l" ]; do
             strstr "${l##luks-}" "${luks##luks-}" && return 0
             strstr "$d" "${luks##luks-}" && return 0
+            if [ -n "$dev" ]; then
+                for _dev in "$(devnames $d)"; do
+                    [ "$dev" -ef "$_dev" ] && return 0
+                done
+            fi
         done < /etc/crypttab
     fi
     return 1
diff --git a/modules.d/90crypt/crypt-run-generator.sh b/modules.d/90crypt/crypt-run-generator.sh
index 3c5d7b1..5bf60ec 100755
--- a/modules.d/90crypt/crypt-run-generator.sh
+++ b/modules.d/90crypt/crypt-run-generator.sh
@@ -6,7 +6,7 @@ type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
 dev=$1
 luks=$2
 
-crypttab_contains "$luks" && exit 0
+crypttab_contains "$luks" "$dev" && exit 0
 
 allowdiscards="-"