1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/04.t 211352 2010-08-15 21:24:17Z pjd $ 3 4desc="NFSv4 granular permissions checking - ACL_WRITE_OWNER" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit 10 11echo "1..52" 12 13n0=`namegen` 14n1=`namegen` 15n2=`namegen` 16 17expect 0 mkdir ${n2} 0755 18cdir=`pwd` 19cd ${n2} 20 21# ACL_WRITE_OWNER permits to set gid to our own only. 22expect 0 create ${n0} 0644 23expect 0,0 lstat ${n0} uid,gid 24expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65532 25expect 0,0 lstat ${n0} uid,gid 26expect 0 prependacl ${n0} user:65534:write_owner::allow 27expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65530 28expect 0,0 lstat ${n0} uid,gid 29expect 0 -u 65534 -g 65532,65531 chown ${n0} -1 65532 30expect 0,65532 lstat ${n0} uid,gid 31expect 0 unlink ${n0} 32 33# ACL_WRITE_OWNER permits to set uid to our own only. 34expect 0 create ${n0} 0644 35expect 0,0 lstat ${n0} uid,gid 36expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65534 65531 37expect 0,0 lstat ${n0} uid,gid 38expect 0 prependacl ${n0} user:65534:write_owner::allow 39expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65530 65531 40expect 0,0 lstat ${n0} uid,gid 41expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531 42expect 65534,65531 lstat ${n0} uid,gid 43expect 0 unlink ${n0} 44 45# When non-owner calls chown(2) successfully, set-uid and set-gid bits are 46# removed, except when both uid and gid are equal to -1. 47expect 0 create ${n0} 0644 48expect 0 prependacl ${n0} user:65534:write_owner::allow 49expect 0 chmod ${n0} 06555 50expect 06555 lstat ${n0} mode 51expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 52expect 0555,65534,65532 lstat ${n0} mode,uid,gid 53expect 0 chmod ${n0} 06555 54expect 06555 lstat ${n0} mode 55expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533 56expect 0555,65534,65533 lstat ${n0} mode,uid,gid 57expect 0 chmod ${n0} 06555 58expect 06555 lstat ${n0} mode 59expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1 60expect 06555,65534,65533 lstat ${n0} mode,uid,gid 61expect 0 unlink ${n0} 62 63expect 0 mkdir ${n0} 0755 64expect 0 prependacl ${n0} user:65534:write_owner::allow 65expect 0 chmod ${n0} 06555 66expect 06555 lstat ${n0} mode 67expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 68expect 0555,65534,65532 lstat ${n0} mode,uid,gid 69expect 0 chmod ${n0} 06555 70expect 06555 lstat ${n0} mode 71expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533 72expect 0555,65534,65533 lstat ${n0} mode,uid,gid 73expect 0 chmod ${n0} 06555 74expect 06555 lstat ${n0} mode 75expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1 76expect 06555,65534,65533 lstat ${n0} mode,uid,gid 77expect 0 rmdir ${n0} 78 79cd ${cdir} 80expect 0 rmdir ${n2} 81