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