fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 296
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 296
6 #
7 # Test that xfsdump/restore preserves file capabilities
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/dump
28
29 # real QA test starts here
30
31 # Modify as appropriate.
32 _supported_fs xfs
33 _supported_os Linux
34 _require_scratch
35 _require_command "$SETCAP_PROG" setcap
36 _require_command "$GETCAP_PROG" getcap
37
38 rm -f $seqres.full
39
40 _wipe_fs
41
42 mkdir -p $dump_dir
43 echo test > $dump_dir/testfile
44 # Set a generic xattr
45 setfattr -n user.name -v value $dump_dir/testfile
46 # Now set the cap (which is also an xattr)
47 $SETCAP_PROG cap_setgid,cap_setuid+ep $dump_dir/testfile
48 # And make sure they are there on the source
49 echo "Checking for xattr on source file"
50 getfattr --absolute-names -m user.name $dump_dir/testfile | _dir_filter
51 echo "Checking for capability on source file"
52 $GETCAP_PROG $dump_dir/testfile | _dir_filter
53 getfattr --absolute-names -m security.capability $dump_dir/testfile | _dir_filter
54
55 _do_dump_file -f $tmp.df.0
56 _prepare_restore_dir
57 _do_restore_file
58 # Basic dump/restore checks first - the file is there, right?
59 _ls_compare_sub
60 _diff_compare
61
62 echo "Checking for xattr on restored file"
63 getfattr --absolute-names -m user.name $restore_dir/$dump_sdir/testfile | _dir_filter
64 echo "Checking for capability on restored file"
65 $GETCAP_PROG $restore_dir/$dump_sdir/testfile | _dir_filter
66 getfattr --absolute-names -m security.capability $restore_dir/$dump_sdir/testfile | _dir_filter
67
68 status=0
69 exit