Fix Plymouth passphrase prompt in initramfs script

Entering the ZFS encryption passphrase under Plymouth wasn't working
because in the ZFS initrd script, Plymouth was calling zfs via
"--command", which wasn't passing through the filesystem argument to
zfs load-key properly (it was passing through the single quotes around
the filesystem name intended to handle spaces literally,
which zfs load-key couldn't understand).

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Garrett Fields <ghfields@gmail.com>
Signed-off-by: Richard Allen <belperite@gmail.com>
Issue #9193
Closes #9202
This commit is contained in:
Richard Allen 2019-08-27 21:44:02 +01:00 committed by Tony Hutter
parent 95319fc569
commit ea34735203

View File

@ -411,29 +411,29 @@ decrypt_fs()
# Determine dataset that holds key for root dataset # Determine dataset that holds key for root dataset
ENCRYPTIONROOT=$(${ZFS} get -H -o value encryptionroot "${fs}") ENCRYPTIONROOT=$(${ZFS} get -H -o value encryptionroot "${fs}")
DECRYPT_CMD="${ZFS} load-key '${ENCRYPTIONROOT}'"
# If root dataset is encrypted... # If root dataset is encrypted...
if ! [ "${ENCRYPTIONROOT}" = "-" ]; then if ! [ "${ENCRYPTIONROOT}" = "-" ]; then
TRY_COUNT=3
# Prompt with plymouth, if active # Prompt with plymouth, if active
if [ -e /bin/plymouth ] && /bin/plymouth --ping 2>/dev/null; then if [ -e /bin/plymouth ] && /bin/plymouth --ping 2>/dev/null; then
plymouth ask-for-password --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}" \ while [ $TRY_COUNT -gt 0 ]; do
--number-of-tries="3" \ plymouth ask-for-password --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}" | \
--command="${DECRYPT_CMD}" $ZFS load-key "${ENCRYPTIONROOT}" && break
TRY_COUNT=$((TRY_COUNT - 1))
done
# Prompt with systemd, if active # Prompt with systemd, if active
elif [ -e /run/systemd/system ]; then elif [ -e /run/systemd/system ]; then
TRY_COUNT=3
while [ $TRY_COUNT -gt 0 ]; do while [ $TRY_COUNT -gt 0 ]; do
systemd-ask-password "Encrypted ZFS password for ${ENCRYPTIONROOT}" --no-tty | \ systemd-ask-password "Encrypted ZFS password for ${ENCRYPTIONROOT}" --no-tty | \
${DECRYPT_CMD} && break $ZFS load-key "${ENCRYPTIONROOT}" && break
TRY_COUNT=$((TRY_COUNT - 1)) TRY_COUNT=$((TRY_COUNT - 1))
done done
# Prompt with ZFS tty, otherwise # Prompt with ZFS tty, otherwise
else else
eval "${DECRYPT_CMD}" $ZFS load-key "${ENCRYPTIONROOT}"
fi fi
fi fi
fi fi