X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive-helpers;h=9e455178ce423e6c848bdec993a5b86fcabd7951;hb=ef22a990570cd3658c7a693796e4470994b86fb9;hp=bbed9097aa2d3cd1c6803dd4de9a5ffb49b12a62;hpb=d8df882369aad68caf3ac39692e2196e932ef15b;p=live-boot-grml.git diff --git a/scripts/live-helpers b/scripts/live-helpers index bbed909..9e45517 100644 --- a/scripts/live-helpers +++ b/scripts/live-helpers @@ -311,6 +311,37 @@ try_mount () fi } +open_luks_device () +{ + dev="${1}" + name="$(basename ${dev})" + opts="--key-file=-" + + load_keymap + + while true + do + /lib/cryptsetup/askpass "Enter passphrase for ${dev}: " | \ + /sbin/cryptsetup -T 1 luksOpen ${dev} ${name} ${opts} + + if [ 0 -eq ${?} ] + then + luks_device="/dev/mapper/${name}" + echo ${luks_device} + return 0 + fi + + echo >&6 + echo -n "There was an error decrypting ${dev} ... Retry? [Y/n] " >&6 + read answer + + if [ "$(echo "${answer}" | cut -b1 | tr A-Z a-z)" = "n" ] + then + return 2 + fi + done +} + find_persistent_media () { # Scans devices for overlays and snapshots, and returns a whitespace @@ -344,48 +375,20 @@ find_persistent_media () luks_device="" # Checking for a luks device - if [ "${PERSISTENT_ENCRYPTION}" = "luks" ] && [ -e /sbin/cryptsetup ] + if echo ${PERSISTENT_ENCRYPTION} | grep -qw luks && \ + /sbin/cryptsetup isLuks ${dev} then - if ! modprobe dm-crypt + if luks_device=$(open_luks_device "${dev}") then - log_warning_msg "Unable to load module dm-crypt" - continue - fi - - if [ ! -x /lib/cryptsetup/askpass ] || [ ! -x /sbin/cryptsetup ] - then - log_warning_msg "cryptsetup in unavailable" - continue - fi - - if ! /sbin/cryptsetup isLuks ${dev} - then - # skip device since we strictly want luks devices + dev="${luks_device}" + else + # skip $dev since we failed/chose not to open it continue fi - - load_keymap - - while true - do - /lib/cryptsetup/askpass "Enter passphrase for ${dev}: " | /sbin/cryptsetup -T 1 luksOpen ${dev} $(basename ${dev}) --key-file=- - - if [ 0 -eq ${?} ] - then - luks_device="/dev/mapper/$(basename ${dev})" - dev="${luks_device}" - break - fi - - echo >&6 - echo -n "There was an error decrypting ${dev} ... Retry? [Y/n] " >&6 - read answer - - if [ "$(echo "${answer}" | cut -b1 | tr A-Z a-z)" = "n" ] - then - break - fi - done + elif echo ${PERSISTENT_ENCRYPTION} | grep -qwv none + then + # skip $dev since we don't allow unencrypted storage + continue fi if echo ${PERSISTENT_STORAGE} | grep -qw filesystem