3
# Run this script as root
8
PASSWD_DIR="$HOME_DIR/.ecryptfs/pki"
9
PASSWD_PATH="$PASSWD_DIR/passwd"
17
function write_tmp_files {
18
echo "passwd=t" > $PASSWD_PATH
22
if [ "x$SRC_DIR" == "x" ]; then
23
echo "SRC_DIR is empty"
26
if [ "x$SRC_DIR" == "x/" ]; then
27
echo "SRC_DIR is root; probably not what you want"
35
function mount_passphrase {
36
mount -t ecryptfs $SRC_DIR $DST_DIR -o key=passphrase,cipher=aes,verbosity=0
40
mount -i -o remount,ro $DST_DIR
43
function umount_ecryptfs {
47
function mkdir_clean_mount_passphrase {
48
for i in "passwd=t" "passfile=$HOME_DIR/.ecryptfs/pki/passwd"; do
49
echo "Performing mount with passphrase option [$i]"
50
/sbin/mount.ecryptfs $SRC_DIR $DST_DIR -o key=passphrase:$i,cipher=aes,verbosity=0 > /dev/null
55
echo "Error mounting ecryptfs with passphrase option [$i] [$?]"
62
#we should return errno from calls to libecryptfs functions.
63
function mkdir_clean_mount_bad_passphrase {
64
for i in "passwd=" "passfile="; do
65
echo "Performing mount with passphrase option [$i]"
66
/sbin/mount.ecryptfs $SRC_DIR $DST_DIR -o key=passphrase:$i,cipher=aes,verbosity=0 > /dev/null
71
echo "Return code differed from what was expected [$i]"
78
function mkdir_clean_mount_ciphers {
79
for i in "aes" "des" "cast5" "cast6" "blowfish" "twofish" "des3_ede" ""; do
80
echo "Performing mount with cipher [$i]"
81
/sbin/mount.ecryptfs $SRC_DIR $DST_DIR -o key=passphrase:passwd=t,cipher=$i,verbosity=0 > /dev/null
86
echo "Error mounting ecryptfs with cipher [$i]"
93
function mkdir_clean_mount_bad_ciphers {
94
for i in "aesaaaaaaa" "bbbaes" "xxxaesyyy"; do
95
echo "Performing mount with incorrect cipher [$i]"
96
/sbin/mount.ecryptfs $SRC_DIR $DST_DIR -o key=passphrase:passwd=t,cipher=$i,verbosity=0 > /dev/null
101
echo "Mount should have failed with cipher [$i]"
108
#Salts need to be hex values if a non hex value is specified 0 is used
109
#we should probably clarify that we are requesting a hex value
110
function mkdir_clean_mount_salt {
111
for i in "" "a" "12345678" "0xdeadbeefdeadbeefdeadbeef" "ghijklmn" "sdflajsdflksjdaflsdjk" ""; do
112
echo "Performing mount with salt [$i]"
113
/sbin/mount.ecryptfs $SRC_DIR $DST_DIR -o key=passphrase:passwd=t:salt=$i,cipher=aes,verbosity=0 > /dev/null
118
echo "Error mounting ecryptfs with salt [$i]"
125
function clean_up_tests {
129
echo "Running non-interactive mount tests"
130
echo "Passphrase mount"
132
echo "Making directories"
134
echo "Writing temporary files"
136
echo "Cleaning out source directory"
138
echo "Testing Passphrase Modes"
139
mkdir_clean_mount_passphrase
140
mkdir_clean_mount_bad_passphrase
142
echo "Testing Cipher Modes"
143
mkdir_clean_mount_ciphers
144
mkdir_clean_mount_bad_ciphers
147
mkdir_clean_mount_salt