1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/open/06.t 211352 2010-08-15 21:24:17Z pjd $ 3 4desc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9echo "1..144" 10 11n0=`namegen` 12n1=`namegen` 13 14expect 0 mkdir ${n0} 0755 15expect 0 chown ${n0} 65534 65534 16cdir=`pwd` 17cd ${n0} 18 19# Regular file. 20 21expect 0 -u 65534 -g 65534 create ${n1} 0644 22 23expect 0 -u 65534 -g 65534 chmod ${n1} 0600 24expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY, 25expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY, 26expect 0 -u 65534 -g 65534 open ${n1} O_RDWR, 27expect 0 -u 65534 -g 65534 chmod ${n1} 0060 28expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY, 29expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY, 30expect 0 -u 65533 -g 65534 open ${n1} O_RDWR, 31expect 0 -u 65534 -g 65534 chmod ${n1} 0006 32expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY, 33expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY, 34expect 0 -u 65533 -g 65533 open ${n1} O_RDWR, 35 36expect 0 -u 65534 -g 65534 chmod ${n1} 0477 37expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY, 38expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY, 39expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, 40expect 0 -u 65534 -g 65534 chmod ${n1} 0747 41expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY, 42expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY, 43expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, 44expect 0 -u 65534 -g 65534 chmod ${n1} 0774 45expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY, 46expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY, 47expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, 48 49expect 0 -u 65534 -g 65534 chmod ${n1} 0277 50expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY, 51expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY, 52expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, 53expect 0 -u 65534 -g 65534 chmod ${n1} 0727 54expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY, 55expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY, 56expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, 57expect 0 -u 65534 -g 65534 chmod ${n1} 0772 58expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY, 59expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY, 60expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, 61 62expect 0 -u 65534 -g 65534 chmod ${n1} 0177 63expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY, 64expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY, 65expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, 66expect 0 -u 65534 -g 65534 chmod ${n1} 0717 67expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY, 68expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY, 69expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, 70expect 0 -u 65534 -g 65534 chmod ${n1} 0771 71expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY, 72expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY, 73expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, 74 75expect 0 -u 65534 -g 65534 chmod ${n1} 0077 76expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY, 77expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY, 78expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, 79expect 0 -u 65534 -g 65534 chmod ${n1} 0707 80expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY, 81expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY, 82expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, 83expect 0 -u 65534 -g 65534 chmod ${n1} 0770 84expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY, 85expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY, 86expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, 87 88expect 0 -u 65534 -g 65534 unlink ${n1} 89 90# FIFO. 91 92expect 0 -u 65534 -g 65534 mkfifo ${n1} 0644 93 94expect 0 -u 65534 -g 65534 chmod ${n1} 0600 95expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK 96expect 0 -u 65534 -g 65534 open ${n1} O_RDWR,O_NONBLOCK 97expect 0 -u 65534 -g 65534 chmod ${n1} 0060 98expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK 99expect 0 -u 65533 -g 65534 open ${n1} O_RDWR,O_NONBLOCK 100expect 0 -u 65534 -g 65534 chmod ${n1} 0006 101expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK 102expect 0 -u 65533 -g 65533 open ${n1} O_RDWR,O_NONBLOCK 103 104expect 0 -u 65534 -g 65534 chmod ${n1} 0477 105expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK 106expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY 107expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR 108expect 0 -u 65534 -g 65534 chmod ${n1} 0747 109expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK 110expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY 111expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR 112expect 0 -u 65534 -g 65534 chmod ${n1} 0774 113expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK 114expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY 115expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR 116 117expect 0 -u 65534 -g 65534 chmod ${n1} 0177 118expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY 119expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY 120expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR 121expect 0 -u 65534 -g 65534 chmod ${n1} 0717 122expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY 123expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY 124expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR 125expect 0 -u 65534 -g 65534 chmod ${n1} 0771 126expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY 127expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY 128expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR 129 130expect 0 -u 65534 -g 65534 chmod ${n1} 0077 131expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY 132expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY 133expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR 134expect 0 -u 65534 -g 65534 chmod ${n1} 0707 135expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY 136expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY 137expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR 138expect 0 -u 65534 -g 65534 chmod ${n1} 0770 139expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY 140expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY 141expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR 142 143expect 0 -u 65534 -g 65534 unlink ${n1} 144 145# Directory. 146 147expect 0 -u 65534 -g 65534 mkdir ${n1} 0755 148 149expect 0 -u 65534 -g 65534 chmod ${n1} 0600 150expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY 151expect 0 -u 65534 -g 65534 chmod ${n1} 0060 152expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY 153expect 0 -u 65534 -g 65534 chmod ${n1} 0006 154expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY 155 156expect 0 -u 65534 -g 65534 chmod ${n1} 0477 157expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY 158expect 0 -u 65534 -g 65534 chmod ${n1} 0747 159expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY 160expect 0 -u 65534 -g 65534 chmod ${n1} 0774 161expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY 162 163expect 0 -u 65534 -g 65534 chmod ${n1} 0277 164expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY 165expect 0 -u 65534 -g 65534 chmod ${n1} 0727 166expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY 167expect 0 -u 65534 -g 65534 chmod ${n1} 0772 168expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY 169 170expect 0 -u 65534 -g 65534 chmod ${n1} 0177 171expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY 172expect 0 -u 65534 -g 65534 chmod ${n1} 0717 173expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY 174expect 0 -u 65534 -g 65534 chmod ${n1} 0771 175expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY 176 177expect 0 -u 65534 -g 65534 chmod ${n1} 0077 178expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY 179expect 0 -u 65534 -g 65534 chmod ${n1} 0707 180expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY 181expect 0 -u 65534 -g 65534 chmod ${n1} 0770 182expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY 183 184expect 0 -u 65534 -g 65534 rmdir ${n1} 185 186cd ${cdir} 187expect 0 rmdir ${n0} 188