10.t revision 211180
1217309Snwhitehorn#!/bin/sh 2251843Sbapt# $FreeBSD: head/tools/regression/fstest/tests/chflags/10.t 211180 2010-08-11 16:34:44Z pjd $ 3220749Snwhitehorn 4251843Sbaptdesc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" 5217309Snwhitehorn 6220749Snwhitehorndir=`dirname $0` 7220749Snwhitehorn. ${dir}/../misc.sh 8220749Snwhitehorn 9220749Snwhitehornrequire chflags 10220749Snwhitehorn 11220749Snwhitehornecho "1..210" 12220749Snwhitehorn 13220749Snwhitehornn0=`namegen` 14220749Snwhitehornn1=`namegen` 15220749Snwhitehornn2=`namegen` 16220749Snwhitehorn 17220749Snwhitehornexpect 0 mkdir ${n0} 0755 18220749Snwhitehorncdir=`pwd` 19220749Snwhitehorncd ${n0} 20220749Snwhitehorn 21220749Snwhitehornfor type in regular dir fifo block char socket symlink; do 22220749Snwhitehorn if [ "${type}" != "symlink" ]; then 23220749Snwhitehorn create_file ${type} ${n1} 0 0 24220749Snwhitehorn expect 0 chown ${n1} 65534 65534 25220749Snwhitehorn for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 26220749Snwhitehorn expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag} 27220749Snwhitehorn expect none stat ${n1} flags 28220749Snwhitehorn expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag} 29220749Snwhitehorn expect none stat ${n1} flags 30217309Snwhitehorn done 31217309Snwhitehorn if [ "${type}" = "dir" ]; then 32217309Snwhitehorn expect 0 rmdir ${n1} 33217309Snwhitehorn else 34251843Sbapt expect 0 unlink ${n1} 35217309Snwhitehorn fi 36217309Snwhitehorn fi 37217309Snwhitehorn 38217309Snwhitehorn create_file ${type} ${n1} 0 0 39217309Snwhitehorn expect 0 lchown ${n1} 65534 65534 40217309Snwhitehorn for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 41217309Snwhitehorn expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag} 42217309Snwhitehorn expect none lstat ${n1} flags 43217309Snwhitehorn expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag} 44217309Snwhitehorn expect none lstat ${n1} flags 45217309Snwhitehorn done 46217309Snwhitehorn if [ "${type}" = "dir" ]; then 47217309Snwhitehorn expect 0 rmdir ${n1} 48251843Sbapt else 49217309Snwhitehorn expect 0 unlink ${n1} 50217309Snwhitehorn fi 51217309Snwhitehorndone 52217309Snwhitehorn 53217309Snwhitehorncd ${cdir} 54217309Snwhitehornexpect 0 rmdir ${n0} 55217309Snwhitehorn