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