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