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.
37 # Remove all files from previous tests
40 # Create test file in lower dir
41 lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
42 upperdir=${OVL_BASE_SCRATCH_MNT}/${OVL_UPPER}
44 touch ${lowerdir}/attr_file1
45 chmod 000 ${lowerdir}/attr_file1
46 touch ${lowerdir}/attr_file2
47 chmod 000 ${lowerdir}/attr_file2
51 # copy up by change mode bits and check.
52 chmod a+x ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
53 chmod o-w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
54 chmod g+w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
55 chmod u-r ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
56 chmod a+X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
57 chmod o-s ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
58 chmod g+t ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
59 chmod u-X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
60 stat -c %a ${SCRATCH_MNT}/attr_file1
62 # unprivileged user can't do this.
63 _user_do "chmod a+x ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
64 _user_do "chmod o-w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
65 _user_do "chmod g+w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
66 _user_do "chmod u-r ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
67 _user_do "chmod a+X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
68 _user_do "chmod o-s ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
69 _user_do "chmod g+t ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
70 _user_do "chmod u-X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
71 stat -c %a ${SCRATCH_MNT}/attr_file2
73 # unmount overlayfs but not base fs
74 $UMOUNT_PROG $SCRATCH_MNT
76 # check mode bits of the file that has been copied up, and
77 # the file that should not have been copied up.
78 stat -c %a ${upperdir}/attr_file1