]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/pjdfstest/tests/rmdir/11.t
Update tcsh to git revision 83c5be0 bringing in a number of bug fixes.
[FreeBSD/FreeBSD.git] / contrib / pjdfstest / tests / rmdir / 11.t
1 #!/bin/sh
2 # vim: filetype=sh noexpandtab ts=8 sw=8
3 # $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/11.t 211352 2010-08-15 21:24:17Z pjd $
4
5 desc="rmdir returns EACCES or EPERM if the directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID"
6
7 dir=`dirname $0`
8 . ${dir}/../misc.sh
9
10 echo "1..47"
11
12 n0=`namegen`
13 n1=`namegen`
14 n2=`namegen`
15
16 expect 0 mkdir ${n2} 0755
17 cdir=`pwd`
18 cd ${n2}
19
20 expect 0 mkdir ${n0} 0755
21 expect 0 chown ${n0} 65534 65534
22 expect 0 chmod ${n0} 01777
23
24 # User owns both: the sticky directory and the directory to be removed.
25 expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
26 expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid
27 expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
28 expect ENOENT lstat ${n0}/${n1} type
29 # User owns the directory to be removed, but doesn't own the sticky directory.
30 for id in 0 65533; do
31         expect 0 chown ${n0} ${id} ${id}
32         create_file dir ${n0}/${n1} 65534 65534
33         expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid
34         expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
35         expect ENOENT lstat ${n0}/${n1} type
36 done
37 # User owns the sticky directory, but doesn't own the directory to be removed.
38 expect 0 chown ${n0} 65534 65534
39 for id in 0 65533; do
40         create_file dir ${n0}/${n1} ${id} ${id}
41         expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid
42         expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
43         expect ENOENT lstat ${n0}/${n1} type
44 done
45 # User doesn't own the sticky directory nor the directory to be removed.
46 for id in 0 65533; do
47         expect 0 chown ${n0} ${id} ${id}
48         create_file dir ${n0}/${n1} ${id} ${id}
49         expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid
50         expect "EACCES|EPERM" -u 65534 -g 65534 rmdir ${n0}/${n1}
51         expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid
52         expect 0 rmdir ${n0}/${n1}
53 done
54
55 expect 0 rmdir ${n0}
56
57 cd ${cdir}
58 expect 0 rmdir ${n2}