140a8ac8fSEnji Cooper#!/bin/sh 2*3416500aSEnji Cooper# vim: filetype=sh noexpandtab ts=8 sw=8 340a8ac8fSEnji Cooper# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $ 440a8ac8fSEnji Cooper 540a8ac8fSEnji Cooperdesc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" 640a8ac8fSEnji Cooper 740a8ac8fSEnji Cooperdir=`dirname $0` 840a8ac8fSEnji Cooper. ${dir}/../misc.sh 940a8ac8fSEnji Cooper 1040a8ac8fSEnji Cooperrequire chflags 1140a8ac8fSEnji Cooper 1240a8ac8fSEnji Cooperecho "1..197" 1340a8ac8fSEnji Cooper 1440a8ac8fSEnji Coopern0=`namegen` 1540a8ac8fSEnji Coopern1=`namegen` 1640a8ac8fSEnji Coopern2=`namegen` 1740a8ac8fSEnji Cooper 1840a8ac8fSEnji Cooperexpect 0 mkdir ${n0} 0755 1940a8ac8fSEnji Coopercdir=`pwd` 2040a8ac8fSEnji Coopercd ${n0} 2140a8ac8fSEnji Cooper 2240a8ac8fSEnji Cooperfor type in regular dir fifo block char socket symlink; do 2340a8ac8fSEnji Cooper if [ "${type}" != "symlink" ]; then 2440a8ac8fSEnji Cooper create_file ${type} ${n1} 2540a8ac8fSEnji Cooper expect 0 chown ${n1} 65534 65534 2640a8ac8fSEnji Cooper for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 2740a8ac8fSEnji Cooper expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag} 2840a8ac8fSEnji Cooper expect none stat ${n1} flags 2940a8ac8fSEnji Cooper expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag} 3040a8ac8fSEnji Cooper expect none stat ${n1} flags 3140a8ac8fSEnji Cooper done 3240a8ac8fSEnji Cooper if [ "${type}" = "dir" ]; then 3340a8ac8fSEnji Cooper expect 0 rmdir ${n1} 3440a8ac8fSEnji Cooper else 3540a8ac8fSEnji Cooper expect 0 unlink ${n1} 3640a8ac8fSEnji Cooper fi 3740a8ac8fSEnji Cooper fi 3840a8ac8fSEnji Cooper 3940a8ac8fSEnji Cooper create_file ${type} ${n1} 4040a8ac8fSEnji Cooper expect 0 lchown ${n1} 65534 65534 4140a8ac8fSEnji Cooper for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 4240a8ac8fSEnji Cooper expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag} 4340a8ac8fSEnji Cooper expect none lstat ${n1} flags 4440a8ac8fSEnji Cooper expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag} 4540a8ac8fSEnji Cooper expect none lstat ${n1} flags 4640a8ac8fSEnji Cooper done 4740a8ac8fSEnji Cooper if [ "${type}" = "dir" ]; then 4840a8ac8fSEnji Cooper expect 0 rmdir ${n1} 4940a8ac8fSEnji Cooper else 5040a8ac8fSEnji Cooper expect 0 unlink ${n1} 5140a8ac8fSEnji Cooper fi 5240a8ac8fSEnji Cooperdone 5340a8ac8fSEnji Cooper 5440a8ac8fSEnji Coopercd ${cdir} 5540a8ac8fSEnji Cooperexpect 0 rmdir ${n0} 56