1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $ 3 4desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11echo "1..197" 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 EPERM -u 65533 -g 65533 chflags ${n1} ${flag} 27 expect none stat ${n1} flags 28 expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag} 29 expect none stat ${n1} flags 30 done 31 if [ "${type}" = "dir" ]; then 32 expect 0 rmdir ${n1} 33 else 34 expect 0 unlink ${n1} 35 fi 36 fi 37 38 create_file ${type} ${n1} 39 expect 0 lchown ${n1} 65534 65534 40 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 41 expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag} 42 expect none lstat ${n1} flags 43 expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag} 44 expect none lstat ${n1} flags 45 done 46 if [ "${type}" = "dir" ]; then 47 expect 0 rmdir ${n1} 48 else 49 expect 0 unlink ${n1} 50 fi 51done 52 53cd ${cdir} 54expect 0 rmdir ${n0} 55