xref: /freebsd/contrib/pjdfstest/tests/rename/21.t (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/21.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="write access to subdirectory is required to move it to another directory"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10echo "1..16"
11
12n0=`namegen`
13n1=`namegen`
14n2=`namegen`
15n3=`namegen`
16
17expect 0 mkdir ${n2} 0777
18expect 0 mkdir ${n3} 0777
19cdir=`pwd`
20
21# Check that write permission on containing directory (${n2}) is enough
22# to rename subdirectory (${n0}). If we rename directory write access
23# to this directory may also be required.
24expect 0 mkdir ${n2}/${n0} 0700
25expect "0|EACCES" -u 65534 -g 65534 rename ${n2}/${n0} ${n2}/${n1}
26expect "0|EACCES" -u 65534 -g 65534 rename ${n2}/${n1} ${n2}/${n0}
27
28# Check that write permission on containing directory (${n2}) is not enough
29# to move subdirectory (${n0}) from that directory.
30# Actually POSIX says that write access to ${n2} and ${n3} may be enough
31# to move ${n0} from ${n2} to ${n3}.
32expect "0|EACCES" -u 65534 -g 65534 rename ${n2}/${n0} ${n3}/${n1}
33
34expect "0|ENOENT" rmdir ${n2}/${n0}
35expect ENOENT rmdir ${n2}/${n0}
36expect "0|ENOENT" rmdir ${n3}/${n1}
37expect ENOENT rmdir ${n3}/${n1}
38
39# Check that write permission on containing directory (${n2}) is enough
40# to move file (${n0}) from that directory.
41expect 0 create ${n2}/${n0} 0644
42expect 0 -u 65534 -g 65534 rename ${n2}/${n0} ${n3}/${n1}
43
44expect 0 unlink ${n3}/${n1}
45expect ENOENT unlink ${n2}/${n0}
46
47expect 0 rmdir ${n3}
48expect 0 rmdir ${n2}
49