1166065Spjd#!/bin/sh
2166065Spjd# $FreeBSD: releng/10.2/tools/regression/pjdfstest/tests/chown/00.t 228975 2011-12-30 00:04:11Z uqs $
3166065Spjd
4166065Spjddesc="chown changes ownership"
5166065Spjd
6166065Spjddir=`dirname $0`
7166065Spjd. ${dir}/../misc.sh
8166065Spjd
9166065Spjdif supported lchmod; then
10211350Spjd	echo "1..1349"
11166065Spjdelse
12211350Spjd	echo "1..1323"
13166065Spjdfi
14166065Spjd
15166065Spjdn0=`namegen`
16166065Spjdn1=`namegen`
17166065Spjdn2=`namegen`
18166065Spjd
19166065Spjdexpect 0 mkdir ${n2} 0755
20166065Spjdcdir=`pwd`
21166065Spjdcd ${n2}
22166065Spjd
23166065Spjd# super-user can always modify ownership
24211350Spjdfor type in regular dir fifo block char socket symlink; do
25211350Spjd	if [ "${type}" != "symlink" ]; then
26211350Spjd		create_file ${type} ${n0}
27211180Spjd
28211350Spjd		expect 0 chown ${n0} 123 456
29211350Spjd		expect 123,456 lstat ${n0} uid,gid
30211350Spjd		expect 0 chown ${n0} 0 0
31211350Spjd		expect 0,0 lstat ${n0} uid,gid
32211180Spjd
33211350Spjd		expect 0 symlink ${n0} ${n1}
34211350Spjd		uidgid=`${fstest} lstat ${n1} uid,gid`
35211350Spjd		expect 0 chown ${n1} 123 456
36211350Spjd		expect 123,456 stat ${n1} uid,gid
37211350Spjd		expect 123,456 stat ${n0} uid,gid
38211350Spjd		expect ${uidgid} lstat ${n1} uid,gid
39211350Spjd		expect 0 unlink ${n1}
40211180Spjd
41211350Spjd		if [ "${type}" = "dir" ]; then
42211350Spjd			expect 0 rmdir ${n0}
43211350Spjd		else
44211350Spjd			expect 0 unlink ${n0}
45211350Spjd		fi
46211350Spjd	fi
47211180Spjd
48211350Spjd	create_file ${type} ${n0}
49211350Spjd	expect 0 lchown ${n0} 123 456
50211350Spjd	expect 123,456 lstat ${n0} uid,gid
51211350Spjd	if [ "${type}" = "dir" ]; then
52211350Spjd		expect 0 rmdir ${n0}
53211350Spjd	else
54211350Spjd		expect 0 unlink ${n0}
55211350Spjd	fi
56211350Spjddone
57211180Spjd
58211350Spjd# non-super-user can modify file group if he is owner of a file and
59211350Spjd# gid he is setting is in his groups list.
60211350Spjdfor type in regular dir fifo block char socket symlink; do
61211350Spjd	if [ "${type}" != "symlink" ]; then
62211350Spjd		create_file ${type} ${n0}
63211180Spjd
64211350Spjd		expect 0 chown ${n0} 65534 65533
65211350Spjd		expect 65534,65533 lstat ${n0} uid,gid
66211350Spjd		expect 0 -u 65534 -g 65532,65531 -- chown ${n0} -1 65532
67211350Spjd		expect 65534,65532 lstat ${n0} uid,gid
68211350Spjd		expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531
69211350Spjd		expect 65534,65531 lstat ${n0} uid,gid
70211180Spjd
71211350Spjd		expect 0 symlink ${n0} ${n1}
72211350Spjd		uidgid=`${fstest} lstat ${n1} uid,gid`
73211350Spjd		expect 0 chown ${n1} 65534 65533
74211350Spjd		expect 65534,65533 stat ${n0} uid,gid
75211350Spjd		expect 65534,65533 stat ${n1} uid,gid
76211350Spjd		expect ${uidgid} lstat ${n1} uid,gid
77211350Spjd		expect 0 -u 65534 -g 65532,65531 -- chown ${n1} -1 65532
78211350Spjd		expect 65534,65532 stat ${n0} uid,gid
79211350Spjd		expect 65534,65532 stat ${n1} uid,gid
80211350Spjd		expect ${uidgid} lstat ${n1} uid,gid
81211350Spjd		expect 0 -u 65534 -g 65532,65531 chown ${n1} 65534 65531
82211350Spjd		expect 65534,65531 stat ${n0} uid,gid
83211350Spjd		expect 65534,65531 stat ${n1} uid,gid
84211350Spjd		expect ${uidgid} lstat ${n1} uid,gid
85211350Spjd		expect 0 unlink ${n1}
86166065Spjd
87211350Spjd		if [ "${type}" = "dir" ]; then
88211350Spjd			expect 0 rmdir ${n0}
89211350Spjd		else
90211350Spjd			expect 0 unlink ${n0}
91211350Spjd		fi
92211350Spjd	fi
93211180Spjd
94211350Spjd	create_file ${type} ${n0}
95211350Spjd	expect 0 lchown ${n0} 65534 65533
96211350Spjd	expect 65534,65533 lstat ${n0} uid,gid
97211350Spjd	expect 0 -u 65534 -g 65532,65531 -- lchown ${n0} -1 65532
98211350Spjd	expect 65534,65532 lstat ${n0} uid,gid
99211350Spjd	expect 0 -u 65534 -g 65532,65531 lchown ${n0} 65534 65531
100211350Spjd	expect 65534,65531 lstat ${n0} uid,gid
101211350Spjd	if [ "${type}" = "dir" ]; then
102211350Spjd		expect 0 rmdir ${n0}
103211350Spjd	else
104211350Spjd		expect 0 unlink ${n0}
105211350Spjd	fi
106211350Spjddone
107166065Spjd
108166065Spjd# chown(2) return 0 if user is not owner of a file, but chown(2) is called
109166065Spjd# with both uid and gid equal to -1.
110211350Spjdfor type in regular dir fifo block char socket symlink; do
111211350Spjd	if [ "${type}" != "symlink" ]; then
112211350Spjd		create_file ${type} ${n0}
113211180Spjd
114211350Spjd		expect 0 chown ${n0} 65534 65533
115211350Spjd		expect 0 -u 65532 -g 65531 -- chown ${n0} -1 -1
116211350Spjd		expect 65534,65533 stat ${n0} uid,gid
117166065Spjd
118211350Spjd		expect 0 symlink ${n0} ${n1}
119211350Spjd		uidgid=`${fstest} lstat ${n1} uid,gid`
120211350Spjd		expect 0 chown ${n1} 65534 65533
121211350Spjd		expect 65534,65533 stat ${n0} uid,gid
122211350Spjd		expect 65534,65533 stat ${n1} uid,gid
123211350Spjd		expect ${uidgid} lstat ${n1} uid,gid
124211350Spjd		expect 0 -u 65532 -g 65531 -- chown ${n0} -1 -1
125211350Spjd		expect 65534,65533 stat ${n0} uid,gid
126211350Spjd		expect 65534,65533 stat ${n1} uid,gid
127211350Spjd		expect ${uidgid} lstat ${n1} uid,gid
128211350Spjd		expect 0 unlink ${n1}
129211180Spjd
130211350Spjd		if [ "${type}" = "dir" ]; then
131211350Spjd			expect 0 rmdir ${n0}
132211350Spjd		else
133211350Spjd			expect 0 unlink ${n0}
134211350Spjd		fi
135211350Spjd	fi
136211180Spjd
137211350Spjd	create_file ${type} ${n0}
138211350Spjd	expect 0 lchown ${n0} 65534 65533
139211350Spjd	expect 0 -u 65532 -g 65531 -- lchown ${n0} -1 -1
140211350Spjd	expect 65534,65533 lstat ${n0} uid,gid
141211350Spjd	if [ "${type}" = "dir" ]; then
142211350Spjd		expect 0 rmdir ${n0}
143211350Spjd	else
144211350Spjd		expect 0 unlink ${n0}
145211350Spjd	fi
146211350Spjddone
147211180Spjd
148211350Spjd# when super-user calls chown(2), set-uid and set-gid bits may be removed.
149211350Spjdfor type in regular dir fifo block char socket symlink; do
150211350Spjd	if [ "${type}" != "symlink" ]; then
151211350Spjd		create_file ${type} ${n0}
152166065Spjd
153211350Spjd		expect 0 chown ${n0} 65534 65533
154211350Spjd		expect 0 chmod ${n0} 06555
155211350Spjd		expect 06555,65534,65533 stat ${n0} mode,uid,gid
156211350Spjd		expect 0 chown ${n0} 65532 65531
157211350Spjd		expect "(06555|0555),65532,65531" stat ${n0} mode,uid,gid
158211350Spjd		expect 0 chmod ${n0} 06555
159211350Spjd		expect 06555,65532,65531 stat ${n0} mode,uid,gid
160211350Spjd		expect 0 chown ${n0} 0 0
161211350Spjd		expect "(06555|0555),0,0" stat ${n0} mode,uid,gid
162211180Spjd
163211350Spjd		expect 0 symlink ${n0} ${n1}
164211350Spjd		expect 0 chown ${n1} 65534 65533
165211350Spjd		expect 0 chmod ${n1} 06555
166211350Spjd		expect 06555,65534,65533 stat ${n0} mode,uid,gid
167211350Spjd		expect 06555,65534,65533 stat ${n1} mode,uid,gid
168211350Spjd		expect 0 chown ${n1} 65532 65531
169211350Spjd		expect "(06555|0555),65532,65531" stat ${n0} mode,uid,gid
170211350Spjd		expect "(06555|0555),65532,65531" stat ${n1} mode,uid,gid
171211350Spjd		expect 0 chmod ${n1} 06555
172211350Spjd		expect 06555,65532,65531 stat ${n0} mode,uid,gid
173211350Spjd		expect 06555,65532,65531 stat ${n1} mode,uid,gid
174211350Spjd		expect 0 chown ${n1} 0 0
175211350Spjd		expect "(06555|0555),0,0" stat ${n0} mode,uid,gid
176211350Spjd		expect "(06555|0555),0,0" stat ${n1} mode,uid,gid
177211350Spjd		expect 0 unlink ${n1}
178211180Spjd
179211350Spjd		if [ "${type}" = "dir" ]; then
180211350Spjd			expect 0 rmdir ${n0}
181211350Spjd		else
182211350Spjd			expect 0 unlink ${n0}
183211350Spjd		fi
184211350Spjd	fi
185211180Spjd
186211350Spjd	if [ "${type}" != "symlink" ] || supported lchmod; then
187211350Spjd		create_file ${type} ${n0}
188211350Spjd		expect 0 lchown ${n0} 65534 65533
189211350Spjd		if supported lchmod; then
190211350Spjd			expect 0 lchmod ${n0} 06555
191211350Spjd		else
192211350Spjd			expect 0 chmod ${n0} 06555
193211350Spjd		fi
194211350Spjd		expect 06555,65534,65533 lstat ${n0} mode,uid,gid
195211350Spjd		expect 0 lchown ${n0} 65532 65531
196211350Spjd		expect "(06555|0555),65532,65531" lstat ${n0} mode,uid,gid
197211350Spjd		if supported lchmod; then
198211350Spjd			expect 0 lchmod ${n0} 06555
199211350Spjd		else
200211350Spjd			expect 0 chmod ${n0} 06555
201211350Spjd		fi
202211350Spjd		expect 06555,65532,65531 lstat ${n0} mode,uid,gid
203211350Spjd		expect 0 lchown ${n0} 0 0
204211350Spjd		expect "(06555|0555),0,0" lstat ${n0} mode,uid,gid
205211350Spjd		if [ "${type}" = "dir" ]; then
206211350Spjd			expect 0 rmdir ${n0}
207211350Spjd		else
208211350Spjd			expect 0 unlink ${n0}
209211350Spjd		fi
210211350Spjd	fi
211211350Spjddone
212166065Spjd
213211350Spjd# when non-super-user calls chown(2) successfully, set-uid and set-gid bits may
214211350Spjd# be removed, except when both uid and gid are equal to -1.
215211350Spjdfor type in regular dir fifo block char socket symlink; do
216211350Spjd	if [ "${type}" != "symlink" ]; then
217211350Spjd		create_file ${type} ${n0}
218211180Spjd
219211350Spjd		expect 0 chown ${n0} 65534 65533
220211350Spjd		expect 0 chmod ${n0} 06555
221211350Spjd		expect 06555,65534,65533 stat ${n0} mode,uid,gid
222211350Spjd		expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
223211350Spjd		expect 0555,65534,65532 stat ${n0} mode,uid,gid
224211350Spjd		expect 0 chmod ${n0} 06555
225211350Spjd		expect 06555,65534,65532 stat ${n0} mode,uid,gid
226211350Spjd		expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 65533
227211350Spjd		expect 0555,65534,65533 stat ${n0} mode,uid,gid
228211350Spjd		expect 0 chmod ${n0} 06555
229211350Spjd		expect 06555,65534,65533 stat ${n0} mode,uid,gid
230211350Spjd		expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 -1
231211350Spjd		expect "(06555|0555),65534,65533" stat ${n0} mode,uid,gid
232211180Spjd
233211350Spjd		expect 0 symlink ${n0} ${n1}
234211350Spjd		expect 0 chown ${n1} 65534 65533
235211350Spjd		expect 0 chmod ${n1} 06555
236211350Spjd		expect 06555,65534,65533 stat ${n0} mode,uid,gid
237211350Spjd		expect 06555,65534,65533 stat ${n1} mode,uid,gid
238211350Spjd		expect 0 -u 65534 -g 65533,65532 chown ${n1} 65534 65532
239211350Spjd		expect 0555,65534,65532 stat ${n0} mode,uid,gid
240211350Spjd		expect 0555,65534,65532 stat ${n1} mode,uid,gid
241211350Spjd		expect 0 chmod ${n1} 06555
242211350Spjd		expect 06555,65534,65532 stat ${n0} mode,uid,gid
243211350Spjd		expect 06555,65534,65532 stat ${n1} mode,uid,gid
244211350Spjd		expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 65533
245211350Spjd		expect 0555,65534,65533 stat ${n0} mode,uid,gid
246211350Spjd		expect 0555,65534,65533 stat ${n1} mode,uid,gid
247211350Spjd		expect 0 chmod ${n1} 06555
248211350Spjd		expect 06555,65534,65533 stat ${n0} mode,uid,gid
249211350Spjd		expect 06555,65534,65533 stat ${n1} mode,uid,gid
250211350Spjd		expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 -1
251211350Spjd		expect "(06555|0555),65534,65533" stat ${n0} mode,uid,gid
252211350Spjd		expect "(06555|0555),65534,65533" stat ${n1} mode,uid,gid
253211350Spjd		expect 0 unlink ${n1}
254211180Spjd
255211350Spjd		if [ "${type}" = "dir" ]; then
256211350Spjd			expect 0 rmdir ${n0}
257211350Spjd		else
258211350Spjd			expect 0 unlink ${n0}
259211350Spjd		fi
260211350Spjd	fi
261211180Spjd
262211350Spjd	if [ "${type}" != "symlink" ] || supported lchmod; then
263211350Spjd		create_file ${type} ${n0}
264211180Spjd
265211350Spjd		expect 0 lchown ${n0} 65534 65533
266211350Spjd		if supported lchmod; then
267211350Spjd			expect 0 lchmod ${n0} 06555
268211350Spjd		else
269211350Spjd			expect 0 chmod ${n0} 06555
270211350Spjd		fi
271211350Spjd		expect 06555,65534,65533 lstat ${n0} mode,uid,gid
272211350Spjd		expect 0 -u 65534 -g 65533,65532 lchown ${n0} 65534 65532
273211350Spjd		expect 0555,65534,65532 lstat ${n0} mode,uid,gid
274211350Spjd		if supported lchmod; then
275211350Spjd			expect 0 lchmod ${n0} 06555
276211350Spjd		else
277211350Spjd			expect 0 chmod ${n0} 06555
278211350Spjd		fi
279211350Spjd		expect 06555,65534,65532 lstat ${n0} mode,uid,gid
280211350Spjd		expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 65533
281211350Spjd		expect 0555,65534,65533 lstat ${n0} mode,uid,gid
282211350Spjd		if supported lchmod; then
283211350Spjd			expect 0 lchmod ${n0} 06555
284211350Spjd		else
285211350Spjd			expect 0 chmod ${n0} 06555
286211350Spjd		fi
287211350Spjd		expect 06555,65534,65533 lstat ${n0} mode,uid,gid
288211350Spjd		expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 -1
289211350Spjd		expect "(06555|0555),65534,65533" lstat ${n0} mode,uid,gid
290211180Spjd
291211350Spjd		if [ "${type}" = "dir" ]; then
292211350Spjd			expect 0 rmdir ${n0}
293211350Spjd		else
294211350Spjd			expect 0 unlink ${n0}
295211350Spjd		fi
296211350Spjd	fi
297211350Spjddone
298211180Spjd
299228975Suqs# successful chown(2) call (except uid and gid equal to -1) updates ctime.
300211350Spjdfor type in regular dir fifo block char socket symlink; do
301211350Spjd	if [ "${type}" != "symlink" ]; then
302211350Spjd		create_file ${type} ${n0}
303211180Spjd
304211350Spjd		ctime1=`${fstest} stat ${n0} ctime`
305211350Spjd		sleep 1
306211350Spjd		expect 0 chown ${n0} 65534 65533
307211350Spjd		expect 65534,65533 stat ${n0} uid,gid
308211350Spjd		ctime2=`${fstest} stat ${n0} ctime`
309211350Spjd		test_check $ctime1 -lt $ctime2
310211350Spjd		ctime1=`${fstest} stat ${n0} ctime`
311211350Spjd		sleep 1
312211350Spjd		expect 0 -u 65534 -g 65532 chown ${n0} 65534 65532
313211350Spjd		expect 65534,65532 stat ${n0} uid,gid
314211350Spjd		ctime2=`${fstest} stat ${n0} ctime`
315211350Spjd		test_check $ctime1 -lt $ctime2
316211180Spjd
317211350Spjd		expect 0 symlink ${n0} ${n1}
318211350Spjd		ctime1=`${fstest} stat ${n1} ctime`
319211350Spjd		sleep 1
320211350Spjd		expect 0 chown ${n1} 65533 65532
321211350Spjd		expect 65533,65532 stat ${n1} uid,gid
322211350Spjd		ctime2=`${fstest} stat ${n1} ctime`
323211350Spjd		test_check $ctime1 -lt $ctime2
324211350Spjd		ctime1=`${fstest} stat ${n1} ctime`
325211350Spjd		sleep 1
326211350Spjd		expect 0 -u 65533 -g 65531 chown ${n1} 65533 65531
327211350Spjd		expect 65533,65531 stat ${n1} uid,gid
328211350Spjd		ctime2=`${fstest} stat ${n1} ctime`
329211350Spjd		test_check $ctime1 -lt $ctime2
330211350Spjd		expect 0 unlink ${n1}
331211180Spjd
332211350Spjd		if [ "${type}" = "dir" ]; then
333211350Spjd			expect 0 rmdir ${n0}
334211350Spjd		else
335211350Spjd			expect 0 unlink ${n0}
336211350Spjd		fi
337211350Spjd	fi
338211180Spjd
339211350Spjd	create_file ${type} ${n0}
340211180Spjd
341211350Spjd	ctime1=`${fstest} lstat ${n0} ctime`
342211350Spjd	sleep 1
343211350Spjd	expect 0 lchown ${n0} 65534 65533
344211350Spjd	expect 65534,65533 lstat ${n0} uid,gid
345211350Spjd	ctime2=`${fstest} lstat ${n0} ctime`
346211350Spjd	test_check $ctime1 -lt $ctime2
347211350Spjd	ctime1=`${fstest} lstat ${n0} ctime`
348211350Spjd	sleep 1
349211350Spjd	expect 0 -u 65534 -g 65532 lchown ${n0} 65534 65532
350211350Spjd	expect 65534,65532 lstat ${n0} uid,gid
351211350Spjd	ctime2=`${fstest} lstat ${n0} ctime`
352211350Spjd	test_check $ctime1 -lt $ctime2
353211180Spjd
354211350Spjd	if [ "${type}" = "dir" ]; then
355211350Spjd		expect 0 rmdir ${n0}
356211350Spjd	else
357211350Spjd		expect 0 unlink ${n0}
358211350Spjd	fi
359211350Spjddone
360211180Spjd
361211350Spjdfor type in regular dir fifo block char socket symlink; do
362211350Spjd	if [ "${type}" != "symlink" ]; then
363211350Spjd		create_file ${type} ${n0}
364211180Spjd
365211350Spjd		ctime1=`${fstest} stat ${n0} ctime`
366211350Spjd		sleep 1
367211350Spjd		expect 0 -- chown ${n0} -1 -1
368211350Spjd		ctime2=`${fstest} stat ${n0} ctime`
369211350Spjd		todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated."
370211350Spjd		test_check $ctime1 -eq $ctime2
371211350Spjd		expect 0,0 stat ${n0} uid,gid
372211180Spjd
373211350Spjd		expect 0 symlink ${n0} ${n1}
374211350Spjd		ctime1=`${fstest} stat ${n1} ctime`
375211350Spjd		sleep 1
376211350Spjd		expect 0 -- chown ${n1} -1 -1
377211350Spjd		ctime2=`${fstest} stat ${n1} ctime`
378211350Spjd		todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated."
379211350Spjd		test_check $ctime1 -eq $ctime2
380211350Spjd		expect 0,0 stat ${n1} uid,gid
381211350Spjd		expect 0 unlink ${n1}
382211180Spjd
383211350Spjd		if [ "${type}" = "dir" ]; then
384211350Spjd			expect 0 rmdir ${n0}
385211350Spjd		else
386211350Spjd			expect 0 unlink ${n0}
387211350Spjd		fi
388211350Spjd	fi
389211180Spjd
390211350Spjd	create_file ${type} ${n0}
391211180Spjd
392211350Spjd	ctime1=`${fstest} lstat ${n0} ctime`
393211350Spjd	sleep 1
394211350Spjd	expect 0 -- lchown ${n0} -1 -1
395211350Spjd	ctime2=`${fstest} lstat ${n0} ctime`
396211350Spjd	todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated."
397211350Spjd	test_check $ctime1 -eq $ctime2
398211350Spjd	expect 0,0 lstat ${n0} uid,gid
399211180Spjd
400211350Spjd	if [ "${type}" = "dir" ]; then
401211350Spjd		expect 0 rmdir ${n0}
402211350Spjd	else
403211350Spjd		expect 0 unlink ${n0}
404211350Spjd	fi
405211350Spjddone
406211180Spjd
407166065Spjd# unsuccessful chown(2) does not update ctime.
408211350Spjdfor type in regular dir fifo block char socket symlink; do
409211350Spjd	if [ "${type}" != "symlink" ]; then
410211350Spjd		create_file ${type} ${n0}
411211180Spjd
412211350Spjd		ctime1=`${fstest} stat ${n0} ctime`
413211350Spjd		sleep 1
414211350Spjd		expect EPERM -u 65534 -- chown ${n0} 65534 -1
415211350Spjd		expect EPERM -u 65534 -g 65534 -- chown ${n0} -1 65534
416211350Spjd		expect EPERM -u 65534 -g 65534 chown ${n0} 65534 65534
417211350Spjd		ctime2=`${fstest} stat ${n0} ctime`
418211350Spjd		test_check $ctime1 -eq $ctime2
419211350Spjd		expect 0,0 stat ${n0} uid,gid
420211180Spjd
421211350Spjd		expect 0 symlink ${n0} ${n1}
422211350Spjd		ctime1=`${fstest} stat ${n1} ctime`
423211350Spjd		sleep 1
424211350Spjd		expect EPERM -u 65534 -- chown ${n1} 65534 -1
425211350Spjd		expect EPERM -u 65534 -g 65534 -- chown ${n1} -1 65534
426211350Spjd		expect EPERM -u 65534 -g 65534 chown ${n1} 65534 65534
427211350Spjd		ctime2=`${fstest} stat ${n1} ctime`
428211350Spjd		test_check $ctime1 -eq $ctime2
429211350Spjd		expect 0,0 stat ${n1} uid,gid
430211350Spjd		expect 0 unlink ${n1}
431211180Spjd
432211350Spjd		if [ "${type}" = "dir" ]; then
433211350Spjd			expect 0 rmdir ${n0}
434211350Spjd		else
435211350Spjd			expect 0 unlink ${n0}
436211350Spjd		fi
437211350Spjd	fi
438211180Spjd
439211350Spjd	create_file ${type} ${n0}
440211180Spjd
441211350Spjd	ctime1=`${fstest} lstat ${n0} ctime`
442211350Spjd	sleep 1
443211350Spjd	expect EPERM -u 65534 -- lchown ${n0} 65534 -1
444211350Spjd	expect EPERM -u 65534 -g 65534 -- lchown ${n0} -1 65534
445211350Spjd	expect EPERM -u 65534 -g 65534 lchown ${n0} 65534 65534
446211350Spjd	ctime2=`${fstest} lstat ${n0} ctime`
447211350Spjd	test_check $ctime1 -eq $ctime2
448211350Spjd	expect 0,0 lstat ${n0} uid,gid
449211180Spjd
450211350Spjd	if [ "${type}" = "dir" ]; then
451211350Spjd		expect 0 rmdir ${n0}
452211350Spjd	else
453211350Spjd		expect 0 unlink ${n0}
454211350Spjd	fi
455211350Spjddone
456211180Spjd
457166065Spjdcd ${cdir}
458166065Spjdexpect 0 rmdir ${n2}
459