| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Test encrypting a directory using a custom_passphrase protector. |
| 4 |
|
| 5 |
cd "$(dirname "$0")" |
| 6 |
. common.sh |
| 7 |
|
| 8 |
dir="$MNT/dir" |
| 9 |
|
| 10 |
begin() |
| 11 |
{ |
| 12 |
_reset_filesystems |
| 13 |
mkdir "$dir" |
| 14 |
_print_header "$1" |
| 15 |
} |
| 16 |
|
| 17 |
show_status() |
| 18 |
{ |
| 19 |
local encrypted=$1 |
| 20 |
|
| 21 |
fscrypt status "$MNT" |
| 22 |
if $encrypted; then |
| 23 |
fscrypt status "$dir" |
| 24 |
else |
| 25 |
_expect_failure "fscrypt status '$dir'" |
| 26 |
fi |
| 27 |
} |
| 28 |
|
| 29 |
begin "Encrypt with custom passphrase protector" |
| 30 |
echo hunter2 | fscrypt encrypt --quiet --name=prot "$dir" |
| 31 |
show_status true |
| 32 |
|
| 33 |
begin "Encrypt with custom passphrase protector, interactively" |
| 34 |
expect << EOF |
| 35 |
spawn fscrypt encrypt "$dir" |
| 36 |
expect "Enter the source number for the new protector" |
| 37 |
send "2\r" |
| 38 |
expect "Enter a name for the new protector:" |
| 39 |
send "prot\r" |
| 40 |
expect "Enter custom passphrase" |
| 41 |
send "hunter2\r" |
| 42 |
expect "Confirm passphrase" |
| 43 |
send "hunter2\r" |
| 44 |
expect eof |
| 45 |
EOF |
| 46 |
show_status true |
| 47 |
|
| 48 |
begin "Try to use a custom protector without a name" |
| 49 |
_expect_failure "echo hunter2 | fscrypt encrypt --quiet '$dir'" |
| 50 |
show_status false |