2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
7 # Test file copy up on overlayfs by changing mode bits.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
28 # remove previous $seqres.full before test
31 # Modify as appropriate.
36 # Remove all files from previous tests
39 # Create test file in lower dir
40 lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
41 upperdir=${OVL_BASE_SCRATCH_MNT}/${OVL_UPPER}
43 touch ${lowerdir}/attr_file1
44 chmod 000 ${lowerdir}/attr_file1
45 touch ${lowerdir}/attr_file2
46 chmod 000 ${lowerdir}/attr_file2
50 # copy up by change mode bits and check.
51 chmod a+x ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
52 chmod o-w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
53 chmod g+w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
54 chmod u-r ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
55 chmod a+X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
56 chmod o-s ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
57 chmod g+t ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
58 chmod u-X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
59 stat -c %a ${SCRATCH_MNT}/attr_file1
61 # unprivileged user can't do this.
62 _user_do "chmod a+x ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
63 _user_do "chmod o-w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
64 _user_do "chmod g+w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
65 _user_do "chmod u-r ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
66 _user_do "chmod a+X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
67 _user_do "chmod o-s ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
68 _user_do "chmod g+t ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
69 _user_do "chmod u-X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
70 stat -c %a ${SCRATCH_MNT}/attr_file2
72 # unmount overlayfs but not base fs
73 $UMOUNT_PROG $SCRATCH_MNT
75 # check mode bits of the file that has been copied up, and
76 # the file that should not have been copied up.
77 stat -c %a ${upperdir}/attr_file1