diff options
| author | Eric Biggers <ebiggers@google.com> | 2021-12-23 11:39:08 -0600 |
|---|---|---|
| committer | Eric Biggers <ebiggers@google.com> | 2021-12-23 11:39:08 -0600 |
| commit | 57be034ce4700fb07c10b771628c1c63d8483d09 (patch) | |
| tree | 2e9bdfeb26f0d7379c6b6b4186125bd348982ee2 /cli-tests/common.sh | |
| parent | 6ec8ee00398c435aba7cbb68f8246c1772e12908 (diff) | |
cli-tests: add helper functions to get protector descriptors
Diffstat (limited to 'cli-tests/common.sh')
| -rw-r--r-- | cli-tests/common.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cli-tests/common.sh b/cli-tests/common.sh index 0ace2b9..1d7b17b 100644 --- a/cli-tests/common.sh +++ b/cli-tests/common.sh @@ -72,6 +72,40 @@ _get_enabled_fs_count() echo "$count" } +# Gets the descriptor of the given protector. +_get_protector_descriptor() +{ + local mnt=$1 + local source=$2 + + case $source in + custom) + local name=$3 + local description="custom protector \\\"$name\\\"" + ;; + login) + local user=$3 + local description="login protector for $user" + ;; + *) + _fail "Unknown protector source $source" + esac + + local descriptor + descriptor=$(fscrypt status "$mnt" | + awk -F ' *' '{ if ($3 == "'"$description"'") print $1 }') + if [ -z "$descriptor" ]; then + _fail "Can't find $description on $mnt" + fi + echo "$descriptor" +} + +# Gets the descriptor of the login protector for $TEST_USER. +_get_login_descriptor() +{ + _get_protector_descriptor "$MNT_ROOT" login "$TEST_USER" +} + # Prints the number of filesystems that have fscrypt metadata. _get_setup_fs_count() { |