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