summaryrefslogtreecommitdiff
path: root/tests/generic/375
blob: 438184b3081b53dce95329650dc6404c9fe9e2a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2016 Red Hat.  All Rights Reserved.
#
# FS QA Test 375
#
# Check if SGID is cleared upon chmod / setfacl when the owner is not in the
# owning group.
#
. ./common/preamble
_begin_fstest auto quick acl perms

# Import common functions.
. ./common/filter
. ./common/attr

# real QA test starts here
_supported_fs generic
_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