cryptroot-ask.sh: use key file, if specified in crypttab and present
if a key file is specified in crypttab and present in the initramfs use it to open the device. https://bugzilla.redhat.com/show_bug.cgi?id=751640master
parent
dd03dea22e
commit
4e05cb4023
|
@ -34,7 +34,7 @@ fi
|
||||||
|
|
||||||
# TODO: improve to support what cmdline does
|
# TODO: improve to support what cmdline does
|
||||||
if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
|
if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
|
||||||
while read name dev rest; do
|
while read name dev luksfile rest; do
|
||||||
# ignore blank lines and comments
|
# ignore blank lines and comments
|
||||||
if [ -z "$name" -o "${name#\#}" != "$name" ]; then
|
if [ -z "$name" -o "${name#\#}" != "$name" ]; then
|
||||||
continue
|
continue
|
||||||
|
@ -64,8 +64,13 @@ fi
|
||||||
# Open LUKS device
|
# Open LUKS device
|
||||||
#
|
#
|
||||||
|
|
||||||
info "luksOpen $device $luksname"
|
info "luksOpen $device $luksname $luksfile"
|
||||||
|
|
||||||
|
if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then
|
||||||
|
if cryptsetup --key-file "$luksfile" luksOpen "$device" "$luksname"; then
|
||||||
|
ask_passphrase=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
while [ -n "$(getarg rd.luks.key)" ]; do
|
while [ -n "$(getarg rd.luks.key)" ]; do
|
||||||
if tmp=$(getkey /tmp/luks.keys $device); then
|
if tmp=$(getkey /tmp/luks.keys $device); then
|
||||||
keydev="${tmp%%:*}"
|
keydev="${tmp%%:*}"
|
||||||
|
@ -95,6 +100,8 @@ while [ -n "$(getarg rd.luks.key)" ]; do
|
||||||
ask_passphrase=0
|
ask_passphrase=0
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $ask_passphrase -ne 0 ]; then
|
if [ $ask_passphrase -ne 0 ]; then
|
||||||
luks_open="$(command -v cryptsetup) luksOpen"
|
luks_open="$(command -v cryptsetup) luksOpen"
|
||||||
ask_for_password --ply-tries 5 \
|
ask_for_password --ply-tries 5 \
|
||||||
|
@ -105,7 +112,7 @@ if [ $ask_passphrase -ne 0 ]; then
|
||||||
unset luks_open
|
unset luks_open
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset device luksname
|
unset device luksname luksfile
|
||||||
|
|
||||||
# mark device as asked
|
# mark device as asked
|
||||||
>> /tmp/cryptroot-asked-$2
|
>> /tmp/cryptroot-asked-$2
|
||||||
|
|
Loading…
Reference in New Issue