xref: /freebsd/contrib/pjdfstest/tests/open/07.t (revision 531c2d7af3cd2e64eec94aa1b19c4b2f16fce515)
140a8ac8fSEnji Cooper#!/bin/sh
2*3416500aSEnji Cooper# vim: filetype=sh noexpandtab ts=8 sw=8
340a8ac8fSEnji Cooper# $FreeBSD: head/tools/regression/pjdfstest/tests/open/07.t 211352 2010-08-15 21:24:17Z pjd $
440a8ac8fSEnji Cooper
540a8ac8fSEnji Cooperdesc="open returns EACCES when O_TRUNC is specified and write permission is denied"
640a8ac8fSEnji Cooper
740a8ac8fSEnji Cooperdir=`dirname $0`
840a8ac8fSEnji Cooper. ${dir}/../misc.sh
940a8ac8fSEnji Cooper
1040a8ac8fSEnji Cooperecho "1..23"
1140a8ac8fSEnji Cooper
1240a8ac8fSEnji Coopern0=`namegen`
1340a8ac8fSEnji Coopern1=`namegen`
1440a8ac8fSEnji Cooper
1540a8ac8fSEnji Cooperexpect 0 mkdir ${n0} 0755
1640a8ac8fSEnji Cooperexpect 0 chown ${n0} 65534 65534
1740a8ac8fSEnji Coopercdir=`pwd`
1840a8ac8fSEnji Coopercd ${n0}
1940a8ac8fSEnji Cooper
2040a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 create ${n1} 0644
2140a8ac8fSEnji Cooper
2240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0477
2340a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
2440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0747
2540a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
2640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0774
2740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
2840a8ac8fSEnji Cooper
2940a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0177
3040a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
3140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0717
3240a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
3340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0771
3440a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
3540a8ac8fSEnji Cooper
3640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0077
3740a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
3840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0707
3940a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
4040a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0770
4140a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
4240a8ac8fSEnji Cooper
4340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ${n1}
4440a8ac8fSEnji Cooper
4540a8ac8fSEnji Coopercd ${cdir}
4640a8ac8fSEnji Cooperexpect 0 rmdir ${n0}
47