140a8ac8fSEnji Cooper#!/bin/sh 2*3416500aSEnji Cooper# vim: filetype=sh noexpandtab ts=8 sw=8 340a8ac8fSEnji Cooper# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/00.t 211352 2010-08-15 21:24:17Z pjd $ 440a8ac8fSEnji Cooper 540a8ac8fSEnji Cooperdesc="NFSv4 granular permissions checking - WRITE_DATA vs APPEND_DATA on directories" 640a8ac8fSEnji Cooper 740a8ac8fSEnji Cooperdir=`dirname $0` 840a8ac8fSEnji Cooper. ${dir}/../misc.sh 940a8ac8fSEnji Cooper 1040a8ac8fSEnji Cooper[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit 1140a8ac8fSEnji Cooper 1240a8ac8fSEnji Cooperecho "1..49" 1340a8ac8fSEnji Cooper 1440a8ac8fSEnji Coopern0=`namegen` 1540a8ac8fSEnji Coopern1=`namegen` 1640a8ac8fSEnji Coopern2=`namegen` 1740a8ac8fSEnji Coopern3=`namegen` 1840a8ac8fSEnji Cooper 1940a8ac8fSEnji Cooperexpect 0 mkdir ${n2} 0755 2040a8ac8fSEnji Cooperexpect 0 mkdir ${n3} 0777 2140a8ac8fSEnji Coopercdir=`pwd` 2240a8ac8fSEnji Coopercd ${n2} 2340a8ac8fSEnji Cooper 2440a8ac8fSEnji Cooper# Tests 2..7 - check out whether root user can do stuff. 2540a8ac8fSEnji Cooper# Can create files? 2640a8ac8fSEnji Cooperexpect 0 create ${n0} 0644 2740a8ac8fSEnji Cooper 2840a8ac8fSEnji Cooper# Can create symlinks? 2940a8ac8fSEnji Cooperexpect 0 link ${n0} ${n1} 3040a8ac8fSEnji Cooperexpect 0 unlink ${n1} 3140a8ac8fSEnji Cooperexpect 0 unlink ${n0} 3240a8ac8fSEnji Cooper 3340a8ac8fSEnji Cooper# Can create directories? 3440a8ac8fSEnji Cooperexpect 0 mkdir ${n0} 0755 3540a8ac8fSEnji Cooperexpect 0 rmdir ${n0} 3640a8ac8fSEnji Cooper 3740a8ac8fSEnji Cooper# Check whether user 65534 is permitted to create and remove 3840a8ac8fSEnji Cooper# files, but not subdirectories. 3940a8ac8fSEnji Cooperexpect 0 prependacl . user:65534:write_data::allow,user:65534:append_data::deny 4040a8ac8fSEnji Cooper 4140a8ac8fSEnji Cooper# Can create files? 4240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 create ${n0} 0644 4340a8ac8fSEnji Cooper 4440a8ac8fSEnji Cooper# Can create symlinks? 4540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 link ${n0} ${n1} 4640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ${n1} 4740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ${n0} 4840a8ac8fSEnji Cooper 4940a8ac8fSEnji Cooper# Can create directories? 5040a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 mkdir ${n0} 0755 5140a8ac8fSEnji Cooperexpect ENOENT -u 65534 -g 65534 rmdir ${n0} 5240a8ac8fSEnji Cooperexpect 0 mkdir ${n0} 0755 5340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rmdir ${n0} 5440a8ac8fSEnji Cooper 5540a8ac8fSEnji Cooper# Can move files from other directory? 5640a8ac8fSEnji Cooperexpect 0 create ../${n3}/${n1} 0644 5740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 5840a8ac8fSEnji Cooper 5940a8ac8fSEnji Cooper# Can move files from other directory overwriting existing files? 6040a8ac8fSEnji Cooperexpect 0 create ../${n3}/${n1} 0644 6140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 6240a8ac8fSEnji Cooper 6340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ${n0} 6440a8ac8fSEnji Cooper 6540a8ac8fSEnji Cooper# Can move directories from other directory? 6640a8ac8fSEnji Cooperexpect 0 mkdir ../${n3}/${n1} 0777 6740a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 6840a8ac8fSEnji Cooper 6940a8ac8fSEnji Cooper# Can move directories from other directory overwriting existing directory? 7040a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 7140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rmdir ../${n3}/${n1} 7240a8ac8fSEnji Cooper 7340a8ac8fSEnji Cooper# Check whether user 65534 is permitted to create 7440a8ac8fSEnji Cooper# subdirectories, but not files - and to remove neither of them. 7540a8ac8fSEnji Cooperexpect 0 prependacl . user:65534:write_data::deny,user:65534:append_data::allow 7640a8ac8fSEnji Cooper 7740a8ac8fSEnji Cooper# Can create files? 7840a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 create ${n0} 0644 7940a8ac8fSEnji Cooper 8040a8ac8fSEnji Cooper# Can create symlinks? 8140a8ac8fSEnji Cooperexpect 0 create ${n0} 0644 8240a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 link ${n0} ${n1} 8340a8ac8fSEnji Cooperexpect ENOENT -u 65534 -g 65534 unlink ${n1} 8440a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 unlink ${n0} 8540a8ac8fSEnji Cooperexpect 0 unlink ${n0} 8640a8ac8fSEnji Cooper 8740a8ac8fSEnji Cooper# Can create directories? 8840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 mkdir ${n0} 0755 8940a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 rmdir ${n0} 9040a8ac8fSEnji Cooperexpect 0 rmdir ${n0} 9140a8ac8fSEnji Cooper 9240a8ac8fSEnji Cooper# Can move files from other directory? 9340a8ac8fSEnji Cooperexpect 0 create ../${n3}/${n1} 0644 9440a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 9540a8ac8fSEnji Cooper 9640a8ac8fSEnji Cooper# Can move files from other directory overwriting existing files? 9740a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 9840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ../${n3}/${n1} 9940a8ac8fSEnji Cooper 10040a8ac8fSEnji Cooper# Can move directories from other directory? 10140a8ac8fSEnji Cooperexpect 0 mkdir ../${n3}/${n1} 0777 10240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 10340a8ac8fSEnji Cooper 10440a8ac8fSEnji Cooper# Can move directories from other directory overwriting existing directory? 10540a8ac8fSEnji Cooperexpect 0 mkdir ../${n3}/${n1} 0777 10640a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 10740a8ac8fSEnji Cooperexpect 0 prependacl . user:65534:delete_child::allow 10840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} 10940a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rmdir ${n0} 11040a8ac8fSEnji Cooper 11140a8ac8fSEnji Coopercd ${cdir} 11240a8ac8fSEnji Cooperexpect 0 rmdir ${n2} 11340a8ac8fSEnji Cooperexpect 0 rmdir ${n3} 114