File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,6 +72,40 @@ _get_enabled_fs_count()
7272 echo " $count "
7373}
7474
75+ # Gets the descriptor of the given protector.
76+ _get_protector_descriptor ()
77+ {
78+ local mnt=$1
79+ local source=$2
80+
81+ case $source in
82+ custom)
83+ local name=$3
84+ local description=" custom protector \\\" $name \\\" "
85+ ;;
86+ login)
87+ local user=$3
88+ local description=" login protector for $user "
89+ ;;
90+ * )
91+ _fail " Unknown protector source $source "
92+ esac
93+
94+ local descriptor
95+ descriptor=$( fscrypt status " $mnt " |
96+ awk -F ' *' ' { if ($3 == "' " $description " ' ") print $1 }' )
97+ if [ -z " $descriptor " ]; then
98+ _fail " Can't find $description on $mnt "
99+ fi
100+ echo " $descriptor "
101+ }
102+
103+ # Gets the descriptor of the login protector for $TEST_USER.
104+ _get_login_descriptor ()
105+ {
106+ _get_protector_descriptor " $MNT_ROOT " login " $TEST_USER "
107+ }
108+
75109# Prints the number of filesystems that have fscrypt metadata.
76110_get_setup_fs_count ()
77111{
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ echo pass1 | fscrypt encrypt --quiet --name=prot --skip-unlock "$dir"
1414_print_header " Try to unlock with wrong passphrase"
1515_expect_failure " echo pass2 | fscrypt unlock --quiet '$dir '"
1616_expect_failure " mkdir '$dir /subdir'"
17- protector=$( fscrypt status " $dir " | awk ' / custom protector/{print $1} ' )
17+ protector=$( _get_protector_descriptor " $dir " custom prot )
1818
1919_print_header " Change passphrase"
2020echo $' pass1\n pass2' | \
Original file line number Diff line number Diff line change @@ -27,18 +27,13 @@ show_status()
2727 fi
2828}
2929
30- get_login_protector ()
31- {
32- fscrypt status " $dir " | awk ' /login protector/{print $1}'
33- }
34-
3530begin " Encrypt with login protector"
3631chown " $TEST_USER " " $dir "
3732_user_do " echo TEST_USER_PASS | fscrypt encrypt --quiet --source=pam_passphrase '$dir '"
3833show_status true
3934recovery_passphrase=$( grep -E ' ^ +[a-z]{20}$' " $dir /fscrypt_recovery_readme.txt" | sed ' s/^ +//' )
40- recovery_protector=$( fscrypt status " $dir " | awk ' / Recovery passphrase/{print $1} ' )
41- login_protector=$( get_login_protector )
35+ recovery_protector=$( _get_protector_descriptor " $MNT " custom ' Recovery passphrase for dir ' )
36+ login_protector=$( _get_login_descriptor )
4237_print_header " => Lock, then unlock with login passphrase"
4338_user_do " fscrypt lock '$dir '"
4439# FIXME: should we be able to use $MNT:$login_protector here?
@@ -63,7 +58,7 @@ begin "Encrypt with login protector as root"
6358echo TEST_USER_PASS | fscrypt encrypt --quiet --source=pam_passphrase --user=" $TEST_USER " " $dir "
6459show_status true
6560# The newly-created login protector should be owned by the user, not root.
66- login_protector=$( get_login_protector )
61+ login_protector=$( _get_login_descriptor )
6762owner=$( stat -c " %U:%G" " $MNT_ROOT /.fscrypt/protectors/$login_protector " )
6863echo -e " \nProtector is owned by $owner "
6964
You can’t perform that action at this time.
0 commit comments