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