git: 408087f128fe - main - zfskeys: allow prompt to entered during boot up

From: Doug Ambrisko <ambrisko_at_FreeBSD.org>
Date: Thu, 12 Sep 2024 16:34:28 UTC
The branch main has been updated by ambrisko:

URL: https://cgit.FreeBSD.org/src/commit/?id=408087f128fe745dbfb2b8423f0afd9e0ce2d11a

commit 408087f128fe745dbfb2b8423f0afd9e0ce2d11a
Author:     Doug Ambrisko <ambrisko@FreeBSD.org>
AuthorDate: 2024-09-12 15:43:03 +0000
Commit:     Doug Ambrisko <ambrisko@FreeBSD.org>
CommitDate: 2024-09-12 15:46:49 +0000

    zfskeys: allow prompt to entered during boot up
    
    If the ZFS key is setup in prompt mode, use zfs to prompt to load the key
    during boot to unlock it.
    
    Reviewed by:    jhb
    Differential Revision:  https://reviews.freebsd.org/D36081
---
 libexec/rc/rc.d/zfskeys | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libexec/rc/rc.d/zfskeys b/libexec/rc/rc.d/zfskeys
index ea38182a66c7..aff0224d5c9d 100755
--- a/libexec/rc/rc.d/zfskeys
+++ b/libexec/rc/rc.d/zfskeys
@@ -45,7 +45,15 @@ unlock_fs()
     local kl="$2"
     local k="${kl##file://}"
 
-    if [ "$k" ] && [ -f "$k" ] && [ -s "$k" ] && [ -r "$k" ]; then
+    if [ "$kl" == "prompt" ]
+    then
+        echo "Key prompt for $fs."
+        if zfs load-key -L "$kl" "$fs" < /dev/tty > /dev/tty 2>/dev/tty ; then
+	    echo "Key loaded for $fs."
+        else
+	    echo "Key failed to load for $fs."
+        fi
+    elif [ "$k" ] && [ -f "$k" ] && [ -s "$k" ] && [ -r "$k" ]; then
         if [ "$(zfs get -Ho value keystatus "$fs")" = 'available' ]; then
             echo "Key already loaded for $fs."
         elif keytest=$(zfs load-key -n -L "$kl" "$fs" 2>&1); then