xref: /openbsd/regress/sys/ffs/tests/rename/09.t (revision ec7c50bf)
1*ec7c50bfSpedro#!/bin/sh
2*ec7c50bfSpedro# $FreeBSD: src/tools/regression/fstest/tests/rename/09.t,v 1.1 2007/01/17 01:42:10 pjd Exp $
3*ec7c50bfSpedro
4*ec7c50bfSpedrodesc="rename returns EACCES or EPERM if the directory containing 'from' is marked sticky, and neither the containing directory nor 'from' are owned by the effective user ID"
5*ec7c50bfSpedro
6*ec7c50bfSpedron0=`namegen`
7*ec7c50bfSpedron1=`namegen`
8*ec7c50bfSpedron2=`namegen`
9*ec7c50bfSpedron3=`namegen`
10*ec7c50bfSpedron4=`namegen`
11*ec7c50bfSpedro
12*ec7c50bfSpedroexpect 0 mkdir ${n4} 0755
13*ec7c50bfSpedrocdir=`pwd`
14*ec7c50bfSpedrocd ${n4}
15*ec7c50bfSpedro
16*ec7c50bfSpedroexpect 0 mkdir ${n0} 0755
17*ec7c50bfSpedroexpect 0 chown ${n0} 65534 65534
18*ec7c50bfSpedroexpect 0 chmod ${n0} 01777
19*ec7c50bfSpedro
20*ec7c50bfSpedroexpect 0 mkdir ${n1} 0755
21*ec7c50bfSpedro
22*ec7c50bfSpedro# User owns both: the sticky directory and the file to be renamed.
23*ec7c50bfSpedroexpect 0 chown ${n1} 65534 65534
24*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 create ${n0}/${n2} 0644
25*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
26*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
27*ec7c50bfSpedro# User owns the file to be renamed, but doesn't own the sticky directory.
28*ec7c50bfSpedroexpect 0 chown ${n1} 65533 65533
29*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 create ${n0}/${n2} 0644
30*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3}
31*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
32*ec7c50bfSpedro# User owns the sticky directory, but doesn't own the file to be renamed.
33*ec7c50bfSpedroexpect 0 chown ${n1} 65534 65534
34*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 create ${n0}/${n2} 0644
35*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
36*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
37*ec7c50bfSpedro# User doesn't own the sticky directory nor the file to be renamed.
38*ec7c50bfSpedroexpect 0 chown ${n1} 65533 65533
39*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 create ${n0}/${n2} 0644
40*ec7c50bfSpedroexpect "EACCES|EPERM" -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3}
41*ec7c50bfSpedroexpect 0 unlink ${n0}/${n2}
42*ec7c50bfSpedro
43*ec7c50bfSpedro# User owns both: the sticky directory and the fifo to be renamed.
44*ec7c50bfSpedroexpect 0 chown ${n1} 65534 65534
45*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 mkfifo ${n0}/${n2} 0644
46*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
47*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
48*ec7c50bfSpedro# User owns the fifo to be renamed, but doesn't own the sticky directory.
49*ec7c50bfSpedroexpect 0 chown ${n1} 65533 65533
50*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 mkfifo ${n0}/${n2} 0644
51*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3}
52*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
53*ec7c50bfSpedro# User owns the sticky directory, but doesn't own the fifo to be renamed.
54*ec7c50bfSpedroexpect 0 chown ${n1} 65534 65534
55*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 mkfifo ${n0}/${n2} 0644
56*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
57*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
58*ec7c50bfSpedro# User doesn't own the sticky directory nor the fifo to be renamed.
59*ec7c50bfSpedroexpect 0 chown ${n1} 65533 65533
60*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 mkfifo ${n0}/${n2} 0644
61*ec7c50bfSpedroexpect "EACCES|EPERM" -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3}
62*ec7c50bfSpedroexpect 0 unlink ${n0}/${n2}
63*ec7c50bfSpedro
64*ec7c50bfSpedro# User owns both: the sticky directory and the symlink to be renamed.
65*ec7c50bfSpedroexpect 0 chown ${n1} 65534 65534
66*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 symlink test ${n0}/${n2}
67*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
68*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
69*ec7c50bfSpedro# User owns the symlink to be renamed, but doesn't own the sticky directory.
70*ec7c50bfSpedroexpect 0 chown ${n1} 65533 65533
71*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 symlink test ${n0}/${n2}
72*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3}
73*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
74*ec7c50bfSpedro# User owns the sticky directory, but doesn't own the symlink to be renamed.
75*ec7c50bfSpedroexpect 0 chown ${n1} 65534 65534
76*ec7c50bfSpedroexpect 0 -u 65533 -g 65533 symlink test ${n0}/${n2}
77*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
78*ec7c50bfSpedroexpect 0 unlink ${n1}/${n3}
79*ec7c50bfSpedro# User doesn't own the sticky directory nor the symlink to be renamed.
80*ec7c50bfSpedroexpect 0 chown ${n1} 65533 65533
81*ec7c50bfSpedroexpect 0 -u 65534 -g 65534 symlink test ${n0}/${n2}
82*ec7c50bfSpedroexpect "EACCES|EPERM" -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3}
83*ec7c50bfSpedroexpect 0 unlink ${n0}/${n2}
84*ec7c50bfSpedro
85*ec7c50bfSpedroexpect 0 rmdir ${n1}
86*ec7c50bfSpedroexpect 0 rmdir ${n0}
87*ec7c50bfSpedro
88*ec7c50bfSpedrocd ${cdir}
89*ec7c50bfSpedroexpect 0 rmdir ${n4}
90