1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/11.t 211352 2010-08-15 21:24:17Z pjd $ 3 4desc="rmdir returns EACCES or EPERM if the directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9echo "1..47" 10 11n0=`namegen` 12n1=`namegen` 13n2=`namegen` 14 15expect 0 mkdir ${n2} 0755 16cdir=`pwd` 17cd ${n2} 18 19expect 0 mkdir ${n0} 0755 20expect 0 chown ${n0} 65534 65534 21expect 0 chmod ${n0} 01777 22 23# User owns both: the sticky directory and the directory to be removed. 24expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755 25expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid 26expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1} 27expect ENOENT lstat ${n0}/${n1} type 28# User owns the directory to be removed, but doesn't own the sticky directory. 29for id in 0 65533; do 30 expect 0 chown ${n0} ${id} ${id} 31 create_file dir ${n0}/${n1} 65534 65534 32 expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid 33 expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1} 34 expect ENOENT lstat ${n0}/${n1} type 35done 36# User owns the sticky directory, but doesn't own the directory to be removed. 37expect 0 chown ${n0} 65534 65534 38for id in 0 65533; do 39 create_file dir ${n0}/${n1} ${id} ${id} 40 expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid 41 expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1} 42 expect ENOENT lstat ${n0}/${n1} type 43done 44# User doesn't own the sticky directory nor the directory to be removed. 45for id in 0 65533; do 46 expect 0 chown ${n0} ${id} ${id} 47 create_file dir ${n0}/${n1} ${id} ${id} 48 expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid 49 expect "EACCES|EPERM" -u 65534 -g 65534 rmdir ${n0}/${n1} 50 expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid 51 expect 0 rmdir ${n0}/${n1} 52done 53 54expect 0 rmdir ${n0} 55 56cd ${cdir} 57expect 0 rmdir ${n2} 58