]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
90crypt: enhance crypt-lib keydev mounting
authorLeho Kraav <leho@kraav.com>
Tue, 24 Jul 2012 12:08:52 +0000 (15:08 +0300)
committerHarald Hoyer <harald@redhat.com>
Wed, 25 Jul 2012 08:31:43 +0000 (10:31 +0200)
Combining $keydev and $keypath should result in a unique, re-usable keydev
mountpoint. mkuniqdir doesn't seem to have any an advantage here and lacks
reusability. Is there ever a use case where these are true:

 * there are more than one rd.luks.key=$keypath:$keydev
 * one is actually different from the other

modules.d/90crypt/crypt-lib.sh

index 3aed84df0a17840bd26cd1008a6f09dd9ebb780b..5f7567e35bf039fcf4d1c5eeafad58e2149a3514 100755 (executable)
@@ -165,8 +165,15 @@ readkey() {
     local keydev="$2"
     local device="$3"
 
-    local mntp=$(mkuniqdir /mnt keydev)
-    mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!'
+    # This creates a unique single mountpoint for *, or several for explicitly
+    # given LUKS devices. It accomplishes unlocking multiple LUKS devices with
+    # a single password entry.
+    local mntp="/mnt/$(str_replace "keydev-$keydev-$keypath" '/' '-')"
+
+    if [ ! -d "$mntp" ]; then
+        mkdir "$mntp"
+        mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!'
+    fi
 
     case "${keypath##*.}" in
         gpg)
@@ -188,6 +195,8 @@ readkey() {
         *) cat "$mntp/$keypath" ;;
     esac
 
+    # General unmounting mechanism, modules doing custom cleanup should return earlier
+    # and install a pre-pivot cleanup hook
     umount "$mntp"
     rmdir "$mntp"
 }