summaryrefslogtreecommitdiffstats
path: root/0012-crypt-module-setup.sh-filter-etc-crypttab-in-host-on.patch
blob: 698a708a457813c1ca3ddaa0ad668dde1036e6bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From 96efbc51acd7f65f0f254b17d87da7d0465032c1 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 9 Apr 2013 10:48:26 +0200
Subject: [PATCH] crypt/module-setup.sh: filter /etc/crypttab in host-only mode

only take those /etc/crypttab entries, which we need to boot the system
---
 modules.d/90crypt/module-setup.sh | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh
index b76f6ae..3c9a1f1 100755
--- a/modules.d/90crypt/module-setup.sh
+++ b/modules.d/90crypt/module-setup.sh
@@ -56,7 +56,22 @@ install() {
     if ! dracut_module_included "systemd"; then
         inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
     fi
-    [[ $hostonly ]]  && inst_simple /etc/crypttab
+
+    if [[ $hostonly ]]; then
+        # filter /etc/crypttab for the devices we need
+        while read _mapper _dev _rest; do
+            [[ $_mapper = \#* ]] && continue
+            [[ $_dev ]] || continue
+            for _hdev in "${!host_fs_types[@]}"; do
+                [[ ${host_fs_types[$_hdev]} == "crypto_LUKS" ]] || continue
+                if [[ $_hdev -ef $_dev ]] || [[ /dev/block/$_hdev -ef $_dev ]]; then
+                    echo "$_mapper $_dev $_rest"
+                    break
+                fi
+            done
+        done < /etc/crypttab > $initdir/etc/crypttab
+    fi
+
     inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
 
     dracut_install -o \