90crypt: enhance crypt-lib keydev mounting
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 othermaster
parent
3e9b4330a9
commit
c5758f2090
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue