ab11ed5
From 96efbc51acd7f65f0f254b17d87da7d0465032c1 Mon Sep 17 00:00:00 2001
ab11ed5
From: Harald Hoyer <harald@redhat.com>
ab11ed5
Date: Tue, 9 Apr 2013 10:48:26 +0200
ab11ed5
Subject: [PATCH] crypt/module-setup.sh: filter /etc/crypttab in host-only mode
ab11ed5
ab11ed5
only take those /etc/crypttab entries, which we need to boot the system
ab11ed5
---
ab11ed5
 modules.d/90crypt/module-setup.sh | 17 ++++++++++++++++-
ab11ed5
 1 file changed, 16 insertions(+), 1 deletion(-)
ab11ed5
ab11ed5
diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh
ab11ed5
index b76f6ae..3c9a1f1 100755
ab11ed5
--- a/modules.d/90crypt/module-setup.sh
ab11ed5
+++ b/modules.d/90crypt/module-setup.sh
ab11ed5
@@ -56,7 +56,22 @@ install() {
ab11ed5
     if ! dracut_module_included "systemd"; then
ab11ed5
         inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
ab11ed5
     fi
ab11ed5
-    [[ $hostonly ]]  && inst_simple /etc/crypttab
ab11ed5
+
ab11ed5
+    if [[ $hostonly ]]; then
ab11ed5
+        # filter /etc/crypttab for the devices we need
ab11ed5
+        while read _mapper _dev _rest; do
ab11ed5
+            [[ $_mapper = \#* ]] && continue
ab11ed5
+            [[ $_dev ]] || continue
ab11ed5
+            for _hdev in "${!host_fs_types[@]}"; do
ab11ed5
+                [[ ${host_fs_types[$_hdev]} == "crypto_LUKS" ]] || continue
ab11ed5
+                if [[ $_hdev -ef $_dev ]] || [[ /dev/block/$_hdev -ef $_dev ]]; then
ab11ed5
+                    echo "$_mapper $_dev $_rest"
ab11ed5
+                    break
ab11ed5
+                fi
ab11ed5
+            done
ab11ed5
+        done < /etc/crypttab > $initdir/etc/crypttab
ab11ed5
+    fi
ab11ed5
+
ab11ed5
     inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
ab11ed5
 
ab11ed5
     dracut_install -o \