Files
apfstests/tests/generic/375
T
Eric Biggers 92846328ba generic/375: test both regular file and directory
generic/375 previously only tested SGID being cleared on a regular
file. It should test SGID being cleared on a directory too. Though
this is not required by POSIX, it is the Linux behavior.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-10-13 15:53:46 +08:00

96 lines
2.3 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test 375
#
# Check if SGID is cleared upon chmod / setfacl when the owner is not in the
# owning group.
#
#-----------------------------------------------------------------------
# Copyright (c) 2016 Red Hat. All Rights Reserved.
#
# Author: Andreas gruenbacher <agruenba@redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
# real QA test starts here
_supported_fs generic
_supported_os Linux
_require_test
_require_runas
_require_acls
cd $TEST_DIR
# try with both regular file and directory
for filetype in regular dir; do
case $filetype in
regular)
testfile=testfile.$seq
rm -f $testfile
touch $testfile
;;
*)
testfile=testdir.$seq
rm -rf $testfile
mkdir $testfile
;;
esac
chown 100:100 $testfile
echo '*** SGID should remain set (twice)'
chmod 2755 $testfile
_runas -u 100 -g 100 -- chmod 2777 $testfile
stat -c %A $testfile
chmod 2755 $testfile
_runas -u 100 -g 100 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
stat -c %A $testfile
echo '*** SGID should be cleared (twice)'
chmod 2755 $testfile
_runas -u 100 -g 101 -- chmod 2777 $testfile
stat -c %A $testfile
chmod 2755 $testfile
_runas -u 100 -g 101 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
stat -c %A $testfile
echo '*** Expected failure'
_runas -u 101 -g 101 -- chmod 2777 $testfile
done
status=0
exit