summaryrefslogtreecommitdiffstats
path: root/qa/workunits/fs/misc/acl.sh
blob: 198b05671593d8608c1caefef9701a09b6ff5c7d (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
#!/bin/sh -x

set -e
mkdir -p testdir
cd testdir

set +e
setfacl -d -m u:nobody:rw .
if test $? != 0; then
	echo "Filesystem does not support ACL"
	exit 0
fi

expect_failure() {
	if "$@"; then return 1; else return 0; fi
}

set -e
c=0
while [ $c -lt 100  ]
do
	c=`expr $c + 1`
	# inherited ACL from parent directory's default ACL
	mkdir d1
	c1=`getfacl d1 | grep -c "nobody:rw"`
	echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
	c2=`getfacl d1 | grep -c "nobody:rw"`
	rmdir d1
	if [ $c1 -ne 2 ] || [ $c2 -ne 2 ]
	then
		echo "ERROR: incorrect ACLs"
		exit 1
	fi
done

mkdir d1

# The ACL xattr only contains ACL header. ACL should be removed
# in this case.
setfattr -n system.posix_acl_access -v 0x02000000 d1
setfattr -n system.posix_acl_default -v 0x02000000 .

expect_failure getfattr -n system.posix_acl_access d1
expect_failure getfattr -n system.posix_acl_default .


rmdir d1
cd ..
rmdir testdir
echo OK