efcfb09dfd92bfcc85a12e68ed8d8cf082cc7f6f
[xfstests-dev.git] / 296
1 #! /bin/bash
2 # FS QA Test No. 296
3 #
4 # Test that xfsdump/restore preserves file capabilities
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would 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 the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23 # creator
24 owner=sandeen@sandeen.net
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -f $tmp.*
38 }
39
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43 . ./common.dump
44
45 # real QA test starts here
46
47 # Modify as appropriate.
48 _supported_fs xfs
49 _supported_os Linux
50 _require_scratch
51
52 rm -f $seq.full
53
54 _wipe_fs
55
56 mkdir -p $dump_dir
57 echo test > $dump_dir/testfile
58 # Set a generic xattr
59 setfattr -n user.name -v value $dump_dir/testfile
60 # Now set the cap (which is also an xattr)
61 setcap cap_setgid,cap_setuid+ep $dump_dir/testfile
62 # And make sure they are there on the source
63 echo "Checking for xattr on source file"
64 getfattr --absolute-names -m user.name $dump_dir/testfile | _dir_filter
65 echo "Checking for capability on source file"
66 getcap $dump_dir/testfile | _dir_filter
67 getfattr --absolute-names -m security.capability $dump_dir/testfile | _dir_filter
68
69 _do_dump_file -f $tmp.df.0
70 _prepare_restore_dir
71 _do_restore_file
72 # Basic dump/restore checks first - the file is there, right?
73 _ls_compare_sub
74 _diff_compare
75
76 echo "Checking for xattr on restored file"
77 getfattr --absolute-names -m user.name $restore_dir/$dump_sdir/testfile | _dir_filter
78 echo "Checking for capability on restored file"
79 getcap $restore_dir/$dump_sdir/testfile | _dir_filter
80 getfattr --absolute-names -m security.capability $restore_dir/$dump_sdir/testfile | _dir_filter
81
82 status=0
83 exit