Skip to content

Commit

Permalink
Force systems with kernel option "quiet" to display prompt for password
Browse files Browse the repository at this point in the history
Also exchanged two "${ZFS} get -H -o value" commands to the
initramfs's "get_fs_value()" to maintain script uniformity

Signed-off-by: Garrett Fields <[email protected]>
  • Loading branch information
ghfields committed Dec 16, 2019
1 parent ddb4e69 commit dfb9c6d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions contrib/initramfs/scripts/zfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,11 @@ decrypt_fs()
if [ "$(zpool list -H -o feature@encryption $(echo "${fs}" | awk -F\/ '{print $1}'))" = 'active' ]; then

# Determine dataset that holds key for root dataset
ENCRYPTIONROOT=$(${ZFS} get -H -o value encryptionroot "${fs}")
ENCRYPTIONROOT="$(get_fs_value "${fs}" encryptionroot)"

# If root dataset is encrypted...
if ! [ "${ENCRYPTIONROOT}" = "-" ]; then
KEYSTATUS="$(${ZFS} get -H -o value keystatus "${ENCRYPTIONROOT}")"
KEYSTATUS="$(get_fs_value "${ENCRYPTIONROOT}" keystatus)"
# Continue only if the key needs to be loaded
[ "$KEYSTATUS" = "unavailable" ] || return 0
TRY_COUNT=3
Expand All @@ -436,7 +436,11 @@ decrypt_fs()

# Prompt with ZFS tty, otherwise
else
# Setting "printk" temporarily to "7" will allow prompt even if kernel option "quiet"
storeprintk="$(cat /proc/sys/kernel/printk | awk '{print $1}')"
echo 7 > /proc/sys/kernel/printk
$ZFS load-key "${ENCRYPTIONROOT}"
echo "$storeprintk" > /proc/sys/kernel/printk
fi
fi
fi
Expand Down

0 comments on commit dfb9c6d

Please sign in to comment.