xref: /freebsd/contrib/pjdfstest/tests/rename/04.t (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/04.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="rename returns EACCES when a component of either path prefix denies search permission"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10echo "1..18"
11
12n0=`namegen`
13n1=`namegen`
14n2=`namegen`
15n3=`namegen`
16n4=`namegen`
17
18expect 0 mkdir ${n0} 0755
19cdir=`pwd`
20cd ${n0}
21
22expect 0 mkdir ${n1} 0755
23expect 0 chown ${n1} 65534 65534
24expect 0 mkdir ${n2} 0755
25expect 0 chown ${n2} 65534 65534
26expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644
27
28expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4}
29expect 0 -u 65534 -g 65534 rename ${n2}/${n4} ${n1}/${n3}
30
31expect 0 chmod ${n1} 0644
32expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n1}/${n4}
33expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4}
34
35expect 0 chmod ${n1} 0755
36expect 0 chmod ${n2} 0644
37expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4}
38
39expect 0 unlink ${n1}/${n3}
40expect 0 rmdir ${n1}
41expect 0 rmdir ${n2}
42
43cd ${cdir}
44expect 0 rmdir ${n0}
45