4 # Test file copy up on overlayfs by changing mode bits.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
43 # remove previous $seqres.full before test
46 # Modify as appropriate.
52 # Remove all files from previous tests
55 # Create test file in lower dir
56 lowerdir=${SCRATCH_DEV}/${OVERLAY_LOWER_DIR}
57 upperdir=${SCRATCH_DEV}/${OVERLAY_UPPER_DIR}
59 touch ${lowerdir}/attr_file1
60 chmod 000 ${lowerdir}/attr_file1
61 touch ${lowerdir}/attr_file2
62 chmod 000 ${lowerdir}/attr_file2
66 # copy up by change mode bits and check.
67 chmod a+x ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
68 chmod o-w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
69 chmod g+w ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
70 chmod u-r ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
71 chmod a+X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
72 chmod o-s ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
73 chmod g+t ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
74 chmod u-X ${SCRATCH_MNT}/attr_file1 > /dev/null 2>&1
75 stat -c %a ${SCRATCH_MNT}/attr_file1
77 # unprivileged user can't do this.
78 _user_do "chmod a+x ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
79 _user_do "chmod o-w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
80 _user_do "chmod g+w ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
81 _user_do "chmod u-r ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
82 _user_do "chmod a+X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
83 _user_do "chmod o-s ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
84 _user_do "chmod g+t ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
85 _user_do "chmod u-X ${SCRATCH_MNT}/attr_file2 > /dev/null 2>&1"
86 stat -c %a ${SCRATCH_MNT}/attr_file2
90 # check mode bits of the file that has been copied up, and
91 # the file that should not have been copied up.
92 stat -c %a ${upperdir}/attr_file1