]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/pjdfstest/tests/unlink/11.t
Merge missed sources for lldb-specific TableGen tool.
[FreeBSD/FreeBSD.git] / contrib / pjdfstest / tests / unlink / 11.t
1 #!/bin/sh
2 # vim: filetype=sh noexpandtab ts=8 sw=8
3 # $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/11.t 211352 2010-08-15 21:24:17Z pjd $
4
5 desc="unlink returns EACCES or EPERM if the directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID"
6
7 dir=`dirname $0`
8 . ${dir}/../misc.sh
9
10 echo "1..270"
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 chmod ${n0} 01777
22 expect 0 chown ${n0} 65534 65534
23
24 for type in regular fifo block char socket symlink; do
25         # User owns both: the sticky directory and the file.
26         expect 0 chown ${n0} 65534 65534
27         create_file ${type} ${n0}/${n1} 65534 65534
28         expect ${type},65534,65534 lstat ${n0}/${n1} type,uid,gid
29         expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
30         expect ENOENT lstat ${n0}/${n1} type
31
32         # User owns the sticky directory, but doesn't own the file.
33         for id in 0 65533; do
34                 expect 0 chown ${n0} 65534 65534
35                 create_file ${type} ${n0}/${n1} ${id} ${id}
36                 expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid
37                 expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
38                 expect ENOENT lstat ${n0}/${n1} type
39         done
40
41         # User owns the file, but doesn't own the sticky directory.
42         for id in 0 65533; do
43                 expect 0 chown ${n0} ${id} ${id}
44                 create_file ${type} ${n0}/${n1} 65534 65534
45                 expect ${type},65534,65534 lstat ${n0}/${n1} type,uid,gid
46                 expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
47                 expect ENOENT lstat ${n0}/${n1} type
48         done
49
50         # User doesn't own the sticky directory nor the file.
51         for id in 0 65533; do
52                 expect 0 chown ${n0} ${id} ${id}
53                 create_file ${type} ${n0}/${n1} ${id} ${id}
54                 expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid
55                 expect "EACCES|EPERM" -u 65534 -g 65534 unlink ${n0}/${n1}
56                 expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid
57                 expect 0 unlink ${n0}/${n1}
58         done
59 done
60
61 expect 0 rmdir ${n0}
62
63 cd ${cdir}
64 expect 0 rmdir ${n2}