generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 573
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright 2018 Google LLC
4 #
5 # FS QA Test generic/573
6 #
7 # Test access controls on the fs-verity ioctls.  FS_IOC_MEASURE_VERITY is
8 # allowed on any file, whereas FS_IOC_ENABLE_VERITY requires write access.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         _restore_fsverity_signatures
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/verity
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs generic
36 _require_scratch_verity
37 _require_user
38 _require_chattr ia
39 _disable_fsverity_signatures
40
41 _scratch_mkfs_verity &>> $seqres.full
42 _scratch_mount
43 fsv_file=$SCRATCH_MNT/file.fsv
44
45 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY doesn't require root"
46 echo foo > $fsv_file
47 chmod 666 $fsv_file
48 _user_do "$FSVERITY_PROG enable $fsv_file"
49
50 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires write access"
51 echo foo > $fsv_file >> $seqres.full
52 chmod 444 $fsv_file
53 _user_do "$FSVERITY_PROG enable $fsv_file" |& _filter_scratch
54
55 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires !append-only"
56 echo foo > $fsv_file >> $seqres.full
57 $CHATTR_PROG +a $fsv_file
58 $FSVERITY_PROG enable $fsv_file |& _filter_scratch
59 $CHATTR_PROG -a $fsv_file
60
61 _fsv_scratch_begin_subtest "FS_IOC_ENABLE_VERITY requires !immutable"
62 echo foo > $fsv_file >> $seqres.full
63 $CHATTR_PROG +i $fsv_file
64 $FSVERITY_PROG enable $fsv_file |& _filter_scratch
65 $CHATTR_PROG -i $fsv_file
66
67 _fsv_scratch_begin_subtest "FS_IOC_MEASURE_VERITY doesn't require root"
68 _fsv_create_enable_file $fsv_file >> $seqres.full
69 chmod 444 $fsv_file
70 su $qa_user -c "$FSVERITY_PROG measure $fsv_file" >> $seqres.full
71
72 # success, all done
73 status=0
74 exit