diff --git a/lib/initcpio/hooks/arch_encrypt b/lib/initcpio/hooks/arch_encrypt index ea8cbc15b..e30c2eb6d 100644 --- a/lib/initcpio/hooks/arch_encrypt +++ b/lib/initcpio/hooks/arch_encrypt @@ -15,13 +15,7 @@ run_hook () ckeyfile="/crypto_keyfile.bin" if [ "x${cryptkey}" != "x" ]; then set -- $(/bin/replace "${cryptkey}" ':'); ckdev=$1; ckarg1=$2; ckarg2=$3 - try=10 - echo "Waiting for ${ckdev} ..." - while [ ! -b ${ckdev} -a ${try} -gt 0 ]; do - sleep 1 - try=$((${try}-1)) - done - if [ -b ${ckdev} ]; then + if poll_device "${ckdev}" ${rootdelay}; then case ${ckarg1} in *[!0-9]*) # Use a file on the device @@ -42,13 +36,22 @@ run_hook () fi if [ -n "${cryptdevice}" ]; then + DEPRECATED_CRYPT=0 set -- $(/bin/replace "${cryptdevice}" ':'); cryptdev="$1"; cryptname="$2"; else + DEPRECATED_CRYPT=1 cryptdev="${root}" cryptname="root" fi + warn_deprecated() { + echo "The syntax 'root=${root}' where '${root}' is an encrypted volume is deprecated" + echo "Use 'cryptdevice=${root}:root root=/dev/mapper/root' instead." + } + + if poll_device "${cryptdev}" ${rootdelay}; then if /usr/sbin/cryptsetup isLuks ${cryptdev} >/dev/null 2>&1; then + [ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated dopassphrase=1 # If keyfile exists, try to use that if [ -f ${ckeyfile} ]; then @@ -69,7 +72,7 @@ run_hook () done fi if [ -e "/dev/mapper/${cryptname}" ]; then - if [ "${cryptname}" = "root" ]; then + if [ ${DEPRECATED_CRYPT} -eq 1 ]; then export root="/dev/mapper/root" fi else @@ -77,6 +80,7 @@ run_hook () exit 1 fi elif [ "x${crypto}" != "x" ]; then + [ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated do_oldcrypto () { if [ $# -ne 5 ]; then @@ -109,13 +113,16 @@ run_hook () exit 1 fi if [ -e "/dev/mapper/${cryptname}" ]; then - if [ "${cryptname}" = "root" ]; then + if [ ${DEPRECATED_CRYPT} -eq 1 ]; then export root="/dev/mapper/root" fi else err "Password succeeded, but ${cryptname} creation failed, aborting..." exit 1 fi + else + err "Failed to open encryption mapping: The device ${cryptdev} is not a LUKS volume and the crypto= paramater was not specified." + fi fi nuke ${ckeyfile} fi