xref: /openbsd/regress/sys/ffs/tests/rmdir/11.t (revision 3cab2bb3)
1#!/bin/sh
2# $FreeBSD: src/tools/regression/fstest/tests/rmdir/11.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
3
4desc="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"
5
6n0=`namegen`
7n1=`namegen`
8n2=`namegen`
9
10expect 0 mkdir ${n2} 0755
11cdir=`pwd`
12cd ${n2}
13
14expect 0 mkdir ${n0} 0755
15expect 0 chown ${n0} 65534 65534
16expect 0 chmod ${n0} 01777
17
18# User owns both: the sticky directory and the directory to be removed.
19expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
20expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
21# User owns the directory to be removed, but doesn't own the sticky directory.
22expect 0 -u 65533 -g 65533 mkdir ${n0}/${n1} 0755
23expect 0 -u 65533 -g 65533 rmdir ${n0}/${n1}
24# User owns the sticky directory, but doesn't own the directory to be removed.
25expect 0 -u 65533 -g 65533 mkdir ${n0}/${n1} 0755
26expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
27# User doesn't own the sticky directory nor the directory to be removed.
28expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
29expect "EACCES|EPERM" -u 65533 -g 65533 rmdir ${n0}/${n1}
30expect 0 rmdir ${n0}/${n1}
31
32expect 0 rmdir ${n0}
33
34cd ${cdir}
35expect 0 rmdir ${n2}
36