src/zlevis: specified options

This commit is contained in:
Luc Bijl 2025-02-14 21:22:52 +01:00
parent 44e6d7efd0
commit f022b1fe3c

View file

@ -15,7 +15,7 @@ fi
# Display usage information if input is from a terminal # Display usage information if input is from a terminal
if [ -t 0 ]; then if [ -t 0 ]; then
exec >&2 exec >&2
echo "Usage: zlevis {decrypt|encrypt} {pool|*} [options]" echo "Usage: \"zlevis {decrypt|encrypt} {pool|key} [options]\""
exit 2 exit 2
fi fi
@ -23,13 +23,15 @@ case "$1" in
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;;
*) zlevis-decrypt $2;; key) zlevis-decrypt;;
*) exit 1;;
esac 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;;
*) zlevis-encrypt $2;; key) zlevis-encrypt $3;;
*) exit 1;;
esac esac
;; ;;
*) exit 1;; *) exit 1;;