src/zlevis: removed key option

This commit is contained in:
Luc Bijl 2025-02-19 21:09:44 +01:00
parent 9ac3017da4
commit 5b914c13a3

View file

@ -15,14 +15,14 @@ fi
# Function to display usage information of zlevis # Function to display usage information of zlevis
info() { info() {
exec >&2 exec >&2
echo "Usage: \"zlevis {decrypt|encrypt} {pool|key}\"" echo "Usage: \"zlevis {decrypt|encrypt} <pool>\""
exit 2 exit 2
} }
# Function to display usage information of zlevis encrypt pool # Function to display usage information of zlevis encrypt pool
encrypt_pool_info() { encrypt_pool_info() {
exec >&2 exec >&2
echo "Usage: \"zlevis encrypt pool <pool> '{\"property\":\"value\"}' < file.key\"" echo "Usage: \"zlevis encrypt <pool> '{\"property\":\"value\"}' < file.key\""
echo echo
echo "This command uses the following configuration properties:" echo "This command uses the following configuration properties:"
echo " hash: <string> -> Hash algorithm used in the computation of the object name (default: sha256)." echo " hash: <string> -> Hash algorithm used in the computation of the object name (default: sha256)."
@ -39,14 +39,12 @@ if [ -t 0 ]; then
"decrypt") "decrypt")
case "$2" in case "$2" in
"pool") zfs list -Ho tpm:jwe "$3" | zlevis-decrypt;; "pool") zfs list -Ho tpm:jwe "$3" | zlevis-decrypt;;
"key") zlevis-decrypt;;
*) info;; *) info;;
esac esac
;; ;;
"encrypt") "encrypt")
case "$2" in case "$2" in
"pool") encrypt_pool_info;; "pool") encrypt_pool_info;;
"key") zlevis-encrypt;;
*) info;; *) info;;
esac esac
;; ;;
@ -54,16 +52,9 @@ if [ -t 0 ]; then
esac esac
else else
case "$1" in case "$1" in
"decrypt")
case "$2" in
"key") zlevis-decrypt;;
*) info;;
esac
;;
"encrypt") "encrypt")
case "$2" in case "$2" in
"pool") read -r -d . key || zfs set tpm:jwe=$(printf "%s" "$key" | zlevis-encrypt "$4") "$3";; "pool") read -r -d . key || zfs set tpm:jwe=$(printf "%s" "$key" | zlevis-encrypt "$4") "$3";;
"key") zlevis-encrypt "$3";;
*) info;; *) info;;
esac esac
;; ;;