xref: /freebsd/contrib/pjdfstest/tests/granular/00.t (revision c6db8143eda5c775467145ac73e8ebec47afdd8f)
1#!/bin/sh
2# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/00.t 211352 2010-08-15 21:24:17Z pjd $
3
4desc="NFSv4 granular permissions checking - WRITE_DATA vs APPEND_DATA on directories"
5
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
10
11echo "1..49"
12
13n0=`namegen`
14n1=`namegen`
15n2=`namegen`
16n3=`namegen`
17
18expect 0 mkdir ${n2} 0755
19expect 0 mkdir ${n3} 0777
20cdir=`pwd`
21cd ${n2}
22
23# Tests 2..7 - check out whether root user can do stuff.
24# Can create files?
25expect 0 create ${n0} 0644
26
27# Can create symlinks?
28expect 0 link ${n0} ${n1}
29expect 0 unlink ${n1}
30expect 0 unlink ${n0}
31
32# Can create directories?
33expect 0 mkdir ${n0} 0755
34expect 0 rmdir ${n0}
35
36# Check whether user 65534 is permitted to create and remove
37# files, but not subdirectories.
38expect 0 prependacl . user:65534:write_data::allow,user:65534:append_data::deny
39
40# Can create files?
41expect 0 -u 65534 -g 65534 create ${n0} 0644
42
43# Can create symlinks?
44expect 0 -u 65534 -g 65534 link ${n0} ${n1}
45expect 0 -u 65534 -g 65534 unlink ${n1}
46expect 0 -u 65534 -g 65534 unlink ${n0}
47
48# Can create directories?
49expect EACCES -u 65534 -g 65534 mkdir ${n0} 0755
50expect ENOENT -u 65534 -g 65534 rmdir ${n0}
51expect 0 mkdir ${n0} 0755
52expect 0 -u 65534 -g 65534 rmdir ${n0}
53
54# Can move files from other directory?
55expect 0 create ../${n3}/${n1} 0644
56expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
57
58# Can move files from other directory overwriting existing files?
59expect 0 create ../${n3}/${n1} 0644
60expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
61
62expect 0 -u 65534 -g 65534 unlink ${n0}
63
64# Can move directories from other directory?
65expect 0 mkdir ../${n3}/${n1} 0777
66expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
67
68# Can move directories from other directory overwriting existing directory?
69expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
70expect 0 -u 65534 -g 65534 rmdir ../${n3}/${n1}
71
72# Check whether user 65534 is permitted to create
73# subdirectories, but not files - and to remove neither of them.
74expect 0 prependacl . user:65534:write_data::deny,user:65534:append_data::allow
75
76# Can create files?
77expect EACCES -u 65534 -g 65534 create ${n0} 0644
78
79# Can create symlinks?
80expect 0 create ${n0} 0644
81expect EACCES -u 65534 -g 65534 link ${n0} ${n1}
82expect ENOENT -u 65534 -g 65534 unlink ${n1}
83expect EACCES -u 65534 -g 65534 unlink ${n0}
84expect 0 unlink ${n0}
85
86# Can create directories?
87expect 0 -u 65534 -g 65534 mkdir ${n0} 0755
88expect EACCES -u 65534 -g 65534 rmdir ${n0}
89expect 0 rmdir ${n0}
90
91# Can move files from other directory?
92expect 0 create ../${n3}/${n1} 0644
93expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
94
95# Can move files from other directory overwriting existing files?
96expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
97expect 0 -u 65534 -g 65534 unlink ../${n3}/${n1}
98
99# Can move directories from other directory?
100expect 0 mkdir ../${n3}/${n1} 0777
101expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
102
103# Can move directories from other directory overwriting existing directory?
104expect 0 mkdir ../${n3}/${n1} 0777
105expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
106expect 0 prependacl . user:65534:delete_child::allow
107expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
108expect 0 -u 65534 -g 65534 rmdir ${n0}
109
110cd ${cdir}
111expect 0 rmdir ${n2}
112expect 0 rmdir ${n3}
113