Blame 0012-crypt-module-setup.sh-filter-etc-crypttab-in-host-on.patch

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