~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to tests/kernel/lp-509180.sh

  • Committer: Dustin Kirkland
  • Date: 2009-02-13 15:57:24 UTC
  • Revision ID: kirkland@canonical.com-20090213155724-1q3qz2o0cbyimu9x
debian/ubuntu packaging

Initial checkin of the Debian/Ubuntu packaging

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
#
3
 
# lp-509180.sh: Test for https://launchpad.net/bugs/509180
4
 
# Author: Colin Ian King <colin.king@canonical.com>
5
 
#
6
 
# Copyright (C) 2012 Canonical, Ltd.
7
 
#
8
 
# This program is free software; you can redistribute it and/or
9
 
# modify it under the terms of the GNU General Public License
10
 
# as published by the Free Software Foundation; either version 2
11
 
# of the License, or (at your option) any later version.
12
 
#
13
 
# This program is distributed in the hope that it will be useful,
14
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
# GNU General Public License for more details.
17
 
#
18
 
# You should have received a copy of the GNU General Public License
19
 
# along with this program; if not, write to the Free Software
20
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21
 
 
22
 
test_script_dir=$(dirname $0)
23
 
rc=1
24
 
test_dir=""
25
 
xattr_opt=""
26
 
 
27
 
. ${test_script_dir}/../lib/etl_funcs.sh
28
 
 
29
 
test_cleanup()
30
 
{
31
 
        etl_remove_test_dir $test_dir
32
 
        etl_umount
33
 
        etl_lumount
34
 
        etl_unlink_keys
35
 
        exit $rc
36
 
}
37
 
trap test_cleanup 0 1 2 3 15
38
 
 
39
 
# This test is mainly for the filename encryption case, but it is also valid for
40
 
# plaintext filename support
41
 
etl_add_keys || exit
42
 
etl_lmount || exit
43
 
etl_mount_i || exit
44
 
test_dir=$(etl_create_test_dir) || exit
45
 
 
46
 
# Test method: https://bugs.launchpad.net/ecryptfs/+bug/509180/comments/50
47
 
# Create 1 byte test file
48
 
echo "testing 1 2 3" > $test_dir/test_file
49
 
old_sum=`md5sum $test_dir/test_file | cut -d ' ' -f 1`
50
 
lower_file=`ls $ETL_MOUNT_SRC/ECRYPTFS*/*`
51
 
 
52
 
if etl_is_mount_opt_set "ecryptfs_xattr_metadata" ; then
53
 
        xattr_opt="-x"
54
 
fi
55
 
 
56
 
# Increment 9th byte so that eCryptfs marker fails validation
57
 
${test_script_dir}/lp-509180/test -i $xattr_opt $lower_file || exit
58
 
etl_umount
59
 
 
60
 
etl_mount_i || exit
61
 
cat $test_dir/test_file &> /dev/null
62
 
# Decrement 9th byte so that eCryptfs marker passes validation
63
 
${test_script_dir}/lp-509180/test -d $xattr_opt $lower_file || exit
64
 
new_sum=`md5sum $test_dir/test_file | cut -d ' ' -f 1`
65
 
 
66
 
# md5sums should be the same
67
 
if [ $old_sum = $new_sum ]; then
68
 
        rc=0
69
 
fi
70
 
 
71
 
exit