From f2405d842b69f8114b959d3adf92797bc0152785 Mon Sep 17 00:00:00 2001 From: Luc Date: Sun, 22 Dec 2024 13:24:47 +0100 Subject: [PATCH 1/3] src/zlevis-fetch: added summary and improved zlevis-decrypt check --- src/zlevis-fetch | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/zlevis-fetch b/src/zlevis-fetch index 4faffb2..39c8d0f 100755 --- a/src/zlevis-fetch +++ b/src/zlevis-fetch @@ -3,8 +3,20 @@ # Exit immediately if a command exits with a non-zero status set -e +# Summary of the script's functionality +summary="Decrypts a ZFS root pool with a TPM2.0 chip." + +# Display summary if requested +if [ "$1" = "--summary" ]; then + echo "$summary" + exit 0 +fi + # Check if zlevis-decrypt is present -command -v zlevis-decrypt > /dev/null || exit 1 +if ! command -v zlevis-decrypt > /dev/null; then + echo "Script zlevis-decrypt is not present" + exit 1 +fi # Read ZFS dataset information. zfs list -Ho name,encryption,keystatus,encryptionroot,tpm:jwe | while IFS=$'\t' read -r ds enc keystatus encroot jwe; do @@ -18,8 +30,8 @@ zfs list -Ho name,encryption,keystatus,encryptionroot,tpm:jwe | while IFS=$'\t' echo "Unlocked $ds" else echo "Failed to unlock $ds" >&2 - exit 1 + exit 1 fi fi fi -done \ No newline at end of file +done From ed325fd09b05ed97b8f2b34f7aef3d9e97ffce80 Mon Sep 17 00:00:00 2001 From: Luc Date: Sun, 22 Dec 2024 13:29:11 +0100 Subject: [PATCH 2/3] src/meson.build: added find and test scripts functionality --- src/meson.build | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/meson.build b/src/meson.build index 145e509..509d9af 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,4 +1,14 @@ +# Find scripts +encrypt = find_program('zlevis-encrypt') +decrypt = find_program('zlevis-decrypt') +fetch = find_program('zlevis-fetch') + +# Test the scripts +test('zlevis-encrypt', encrypt, args: '--summary') +test('zlevis-decrypt', decrypt, args: '--summary') +test('zlevis-fetch', fetch, args: '--summary') + # Add paths of scripts to bins bins += join_paths(meson.current_source_dir(), 'zlevis-encrypt') bins += join_paths(meson.current_source_dir(), 'zlevis-decrypt') -bins += join_paths(meson.current_source_dir(), 'zlevis-fetch') +bins += join_paths(meson.current_source_dir(), 'zlevis-fetch') \ No newline at end of file From 31cafc8e7d01f6b2d879403d1ce676b4bbe1498c Mon Sep 17 00:00:00 2001 From: Luc Date: Sun, 22 Dec 2024 13:29:57 +0100 Subject: [PATCH 3/3] meson.build: updated formatting --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 2c824ab..3e6f611 100644 --- a/meson.build +++ b/meson.build @@ -2,10 +2,10 @@ project('zlevis', license: 'GPL3', version: '1') # Define bindir -bindir=join_paths(get_option('prefix'), get_option('bindir')) +bindir = join_paths(get_option('prefix'), get_option('bindir')) # Define bins list -bins=[] +bins = [] # Define subdir with bins subdir('src')