1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z 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..249" 12 13n0=`namegen` 14n1=`namegen` 15n2=`namegen` 16 17expect 0 mkdir ${n0} 0755 18cdir=`pwd` 19cd ${n0} 20 21for type in regular dir fifo block char socket symlink; do 22 if [ "${type}" != "symlink" ]; then 23 create_file ${type} ${n1} 24 expect 0 chown ${n1} 65534 65534 25 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 26 expect 0 chflags ${n1} ${flag} 27 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP 28 expect ${flag} stat ${n1} flags 29 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP 30 expect ${flag} stat ${n1} flags 31 done 32 expect 0 chflags ${n1} none 33 if [ "${type}" = "dir" ]; then 34 expect 0 rmdir ${n1} 35 else 36 expect 0 unlink ${n1} 37 fi 38 fi 39 40 create_file ${type} ${n1} 41 expect 0 lchown ${n1} 65534 65534 42 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 43 expect 0 lchflags ${n1} ${flag} 44 expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP 45 expect ${flag} lstat ${n1} flags 46 expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP 47 expect ${flag} lstat ${n1} flags 48 done 49 expect 0 lchflags ${n1} none 50 if [ "${type}" = "dir" ]; then 51 expect 0 rmdir ${n1} 52 else 53 expect 0 unlink ${n1} 54 fi 55done 56 57cd ${cdir} 58expect 0 rmdir ${n0} 59