]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix Plymouth passphrase prompt in initramfs script
authorRichard Allen <33836503+belperite@users.noreply.github.com>
Tue, 27 Aug 2019 20:44:02 +0000 (21:44 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 27 Aug 2019 20:44:02 +0000 (13:44 -0700)
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

contrib/initramfs/scripts/zfs.in

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