1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/12.t 219463 2011-03-10 20:59:02Z pjd $ 3 4desc="verify SUID/SGID bit behaviour" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9echo "1..14" 10 11n0=`namegen` 12n1=`namegen` 13n2=`namegen` 14 15expect 0 mkdir ${n2} 0755 16cdir=`pwd` 17cd ${n2} 18 19# Check whether writing to the file by non-owner clears the SUID. 20expect 0 create ${n0} 04777 21expect 0777 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x : fstat 0 mode 22expect 0777 stat ${n0} mode 23expect 0 unlink ${n0} 24 25# Check whether writing to the file by non-owner clears the SGID. 26expect 0 create ${n0} 02777 27expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode 28expect 0777 stat ${n0} mode 29expect 0 unlink ${n0} 30 31# Check whether writing to the file by non-owner clears the SUID+SGID. 32expect 0 create ${n0} 06777 33expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode 34expect 0777 stat ${n0} mode 35expect 0 unlink ${n0} 36 37cd ${cdir} 38expect 0 rmdir ${n2} 39