Debian Codegraph @

cli-tests/t_not_enabled.sh

raw
1 #!/bin/bash
2
3 # Test that fscrypt fails when the filesystem doesn't have the encrypt feature
4 # enabled. Then test enabling it.
5
6 cd "$(dirname "$0")"
7 . common.sh
8
9 dir="$MNT/dir"
10 mkdir "$dir"
11
12 _print_header "Disable encryption on $DEV"
13 count_before=$(_get_enabled_fs_count)
14 umount "$MNT"
15 _run_noisy_command "debugfs -w -R 'feature -encrypt' '$DEV'"
16 mount "$DEV" "$MNT"
17 count_after=$(_get_enabled_fs_count)
18 (( count_after == count_before - 1 )) || _fail "wrong enabled count"
19
20 _print_header "Try to encrypt a directory when encryption is disabled"
21 _expect_failure "fscrypt encrypt '$dir'"
22
23 _print_header "Try to unlock a directory when encryption is disabled"
24 _expect_failure "fscrypt unlock '$dir'"
25
26 _print_header "Try to lock a directory when encryption is disabled"
27 _expect_failure "fscrypt lock '$dir'"
28
29 _print_header "Check for additional message when GRUB appears to be installed"
30 mkdir -p "$MNT/boot/grub"
31 _expect_failure "fscrypt encrypt '$dir'"
32 rm -r "${MNT:?}/boot"
33
34 _print_header "Enable encryption on $DEV"
35 _run_noisy_command "tune2fs -O encrypt '$DEV'"
36
37 _print_header "Encrypt a directory when encryption was just enabled"
38 echo hunter2 | fscrypt encrypt --quiet --source=custom_passphrase --name=prot "$dir"
39 fscrypt status "$dir"