08.t revision 166065
1#!/bin/sh 2# $FreeBSD: head/tools/regression/fstest/tests/chflags/08.t 166065 2007-01-17 01:42:12Z pjd $ 3 4desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11echo "1..78" 12 13n0=`namegen` 14n1=`namegen` 15n2=`namegen` 16 17expect 0 mkdir ${n0} 0755 18cdir=`pwd` 19cd ${n0} 20 21expect 0 create ${n1} 0644 22expect 0 chown ${n1} 65534 65534 23for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 24 expect 0 chflags ${n1} ${flag} 25 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE 26 expect ${flag} stat ${n1} flags 27 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE 28 expect ${flag} stat ${n1} flags 29done 30expect 0 chflags ${n1} none 31expect 0 unlink ${n1} 32 33expect 0 mkdir ${n1} 0755 34expect 0 chown ${n1} 65534 65534 35for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 36 expect 0 chflags ${n1} ${flag} 37 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE 38 expect ${flag} stat ${n1} flags 39 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE 40 expect ${flag} stat ${n1} flags 41done 42expect 0 chflags ${n1} none 43expect 0 rmdir ${n1} 44 45expect 0 mkfifo ${n1} 0644 46expect 0 chown ${n1} 65534 65534 47for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 48 expect 0 chflags ${n1} ${flag} 49 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_IMMUTABLE 50 expect ${flag} stat ${n1} flags 51 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_IMMUTABLE 52 expect ${flag} stat ${n1} flags 53done 54expect 0 chflags ${n1} none 55expect 0 unlink ${n1} 56 57expect 0 symlink ${n2} ${n1} 58expect 0 lchown ${n1} 65534 65534 59for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 60 expect 0 lchflags ${n1} ${flag} 61 expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_IMMUTABLE 62 expect ${flag} lstat ${n1} flags 63 expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_IMMUTABLE 64 expect ${flag} lstat ${n1} flags 65done 66expect 0 lchflags ${n1} none 67expect 0 unlink ${n1} 68 69cd ${cdir} 70expect 0 rmdir ${n0} 71