d0d2a5bf9f2a621c8696a3a4b1b2f1f97e858315
[xfstests-dev.git] / tests / overlay / 026
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 026
6 #
7 # Overlayfs should only filter out xattr starting with
8 # "trusted.overlay.", not "trusted.overlay".
9 #
10 # Setting xattrs like "trusted.overlay.xxx" is not allowed.
11 # Setting xattrs like "trusted.overlayxxx" is allowed.
12 #
13 # v4.8-rc1 introduced a regression that we can't set xattrs
14 # like "trusted.overlayxxx".  Kernel commit below fixed it
15 # in v4.8:
16 #   fe2b75952347 ovl: Fix OVL_XATTR_PREFIX
17 #
18 # This case tests both get/set of these 2 kinds of xattrs.
19 #
20 # Pattern "trusted.overlay.xxx" should fail, however the
21 # errno returned by set/get varies among kernel versions.
22 # Pattern "trusted.overlayxxx" shold always work.
23 #
24 # This reproducer was originally written by
25 #     Miklos Szeredi <mszeredi@redhat.com>
26 #
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/attr
45 . ./common/filter
46
47 # remove previous $seqres.full before test
48 rm -f $seqres.full
49
50 # real QA test starts here
51
52 # Modify as appropriate.
53 _supported_fs overlay
54 _supported_os Linux
55 _require_scratch
56 _require_attrs
57
58 # Remove all files from previous tests
59 _scratch_mkfs
60
61 # Mounting overlay
62 _scratch_mount
63 touch $SCRATCH_MNT/testf0
64 touch $SCRATCH_MNT/testf1
65
66 # {s,g}etfattr of "trusted.overlayxxx" should work.
67 #            v4.3/6/7    v4.8-rc1   v4.8  v4.10
68 # setfattr    ok         not perm    ok    ok
69 # getfattr    ok         no attr     ok    ok
70 #
71 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
72   $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
73
74 _getfattr --absolute-names -n "trusted.overlayfsrz" \
75   $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
76
77 # {s,g}etfattr of "trusted.overlay.xxx" should fail.
78 # The errno returned varies among kernel versions,
79 #            v4.3/7   v4.8-rc1    v4.8       v4.10
80 # setfattr  not perm  not perm   not perm   not supp
81 # getfattr  no attr   no attr    not perm   not supp
82 #
83 # Consider "Operation not {supported,permitted}" pass.
84 #
85 $SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
86   $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
87   sed -e 's/permitted/supported/g'
88
89 _getfattr --absolute-names -n "trusted.overlay.fsz" \
90   $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
91   sed -e 's/permitted/supported/g'
92
93 # success, all done
94 status=0
95 exit