1166065Spjd#!/bin/sh 2166065Spjd# $FreeBSD$ 3166065Spjd 4166065Spjddesc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user" 5166065Spjd 6166065Spjddir=`dirname $0` 7166065Spjd. ${dir}/../misc.sh 8166065Spjd 9166065Spjdrequire chflags 10166065Spjd 11211290Spjdecho "1..249" 12166065Spjd 13166065Spjdn0=`namegen` 14166065Spjdn1=`namegen` 15166065Spjdn2=`namegen` 16166065Spjd 17166065Spjdexpect 0 mkdir ${n0} 0755 18166065Spjdcdir=`pwd` 19166065Spjdcd ${n0} 20166065Spjd 21211290Spjdfor type in regular dir fifo block char socket symlink; do 22211290Spjd if [ "${type}" != "symlink" ]; then 23211290Spjd create_file ${type} ${n1} 24211290Spjd expect 0 chown ${n1} 65534 65534 25211290Spjd for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 26211290Spjd expect 0 chflags ${n1} ${flag} 27211290Spjd expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP 28211290Spjd expect ${flag} stat ${n1} flags 29211290Spjd expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP 30211290Spjd expect ${flag} stat ${n1} flags 31211290Spjd done 32211290Spjd expect 0 chflags ${n1} none 33211290Spjd if [ "${type}" = "dir" ]; then 34211290Spjd expect 0 rmdir ${n1} 35211290Spjd else 36211290Spjd expect 0 unlink ${n1} 37211290Spjd fi 38211290Spjd fi 39166065Spjd 40211290Spjd create_file ${type} ${n1} 41211290Spjd expect 0 lchown ${n1} 65534 65534 42211290Spjd for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 43211290Spjd expect 0 lchflags ${n1} ${flag} 44211290Spjd expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP 45211290Spjd expect ${flag} lstat ${n1} flags 46211290Spjd expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP 47211290Spjd expect ${flag} lstat ${n1} flags 48211290Spjd done 49211290Spjd expect 0 lchflags ${n1} none 50211290Spjd if [ "${type}" = "dir" ]; then 51211290Spjd expect 0 rmdir ${n1} 52211290Spjd else 53211290Spjd expect 0 unlink ${n1} 54211290Spjd fi 55166065Spjddone 56166065Spjd 57166065Spjdcd ${cdir} 58166065Spjdexpect 0 rmdir ${n0} 59