xref: /freebsd/contrib/pjdfstest/tests/open/07.t (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/open/07.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="open returns EACCES when O_TRUNC is specified and write permission is denied"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10echo "1..23"
11
12n0=`namegen`
13n1=`namegen`
14
15expect 0 mkdir ${n0} 0755
16expect 0 chown ${n0} 65534 65534
17cdir=`pwd`
18cd ${n0}
19
20expect 0 -u 65534 -g 65534 create ${n1} 0644
21
22expect 0 -u 65534 -g 65534 chmod ${n1} 0477
23expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
24expect 0 -u 65534 -g 65534 chmod ${n1} 0747
25expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
26expect 0 -u 65534 -g 65534 chmod ${n1} 0774
27expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
28
29expect 0 -u 65534 -g 65534 chmod ${n1} 0177
30expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
31expect 0 -u 65534 -g 65534 chmod ${n1} 0717
32expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
33expect 0 -u 65534 -g 65534 chmod ${n1} 0771
34expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
35
36expect 0 -u 65534 -g 65534 chmod ${n1} 0077
37expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC
38expect 0 -u 65534 -g 65534 chmod ${n1} 0707
39expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC
40expect 0 -u 65534 -g 65534 chmod ${n1} 0770
41expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC
42
43expect 0 -u 65534 -g 65534 unlink ${n1}
44
45cd ${cdir}
46expect 0 rmdir ${n0}
47