10.t revision 211186
1166065Spjd#!/bin/sh 2166065Spjd# $FreeBSD: head/tools/regression/fstest/tests/chflags/10.t 211186 2010-08-11 17:34:58Z pjd $ 3166065Spjd 4166065Spjddesc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" 5166065Spjd 6166065Spjddir=`dirname $0` 7166065Spjd. ${dir}/../misc.sh 8166065Spjd 9166065Spjdrequire chflags 10166065Spjd 11211186Spjdecho "1..197" 12166065Spjd 13166065Spjdn0=`namegen` 14166065Spjdn1=`namegen` 15166065Spjdn2=`namegen` 16166065Spjd 17166065Spjdexpect 0 mkdir ${n0} 0755 18166065Spjdcdir=`pwd` 19166065Spjdcd ${n0} 20166065Spjd 21211180Spjdfor type in regular dir fifo block char socket symlink; do 22211180Spjd if [ "${type}" != "symlink" ]; then 23211186Spjd create_file ${type} ${n1} 24211180Spjd expect 0 chown ${n1} 65534 65534 25211180Spjd for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 26211180Spjd expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag} 27211180Spjd expect none stat ${n1} flags 28211180Spjd expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag} 29211180Spjd expect none stat ${n1} flags 30211180Spjd done 31211180Spjd if [ "${type}" = "dir" ]; then 32211180Spjd expect 0 rmdir ${n1} 33211180Spjd else 34211180Spjd expect 0 unlink ${n1} 35211180Spjd fi 36211180Spjd fi 37166065Spjd 38211186Spjd create_file ${type} ${n1} 39211180Spjd expect 0 lchown ${n1} 65534 65534 40211180Spjd for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 41211180Spjd expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag} 42211180Spjd expect none lstat ${n1} flags 43211180Spjd expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag} 44211180Spjd expect none lstat ${n1} flags 45211180Spjd done 46211180Spjd if [ "${type}" = "dir" ]; then 47211180Spjd expect 0 rmdir ${n1} 48211180Spjd else 49211180Spjd expect 0 unlink ${n1} 50211180Spjd fi 51166065Spjddone 52166065Spjd 53166065Spjdcd ${cdir} 54166065Spjdexpect 0 rmdir ${n0} 55