08.t revision 271294
1271294Sngie#!/bin/sh 2271294Sngie# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $ 3271294Sngie 4271294Sngiedesc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user" 5271294Sngie 6271294Sngiedir=`dirname $0` 7271294Sngie. ${dir}/../misc.sh 8271294Sngie 9271294Sngierequire chflags 10271294Sngie 11271294Sngieecho "1..249" 12271294Sngie 13271294Sngien0=`namegen` 14271294Sngien1=`namegen` 15271294Sngien2=`namegen` 16271294Sngie 17271294Sngieexpect 0 mkdir ${n0} 0755 18271294Sngiecdir=`pwd` 19271294Sngiecd ${n0} 20271294Sngie 21271294Sngiefor type in regular dir fifo block char socket symlink; do 22271294Sngie if [ "${type}" != "symlink" ]; then 23271294Sngie create_file ${type} ${n1} 24271294Sngie expect 0 chown ${n1} 65534 65534 25271294Sngie for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 26271294Sngie expect 0 chflags ${n1} ${flag} 27271294Sngie expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP 28271294Sngie expect ${flag} stat ${n1} flags 29271294Sngie expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP 30271294Sngie expect ${flag} stat ${n1} flags 31271294Sngie done 32271294Sngie expect 0 chflags ${n1} none 33271294Sngie if [ "${type}" = "dir" ]; then 34271294Sngie expect 0 rmdir ${n1} 35271294Sngie else 36271294Sngie expect 0 unlink ${n1} 37271294Sngie fi 38271294Sngie fi 39271294Sngie 40271294Sngie create_file ${type} ${n1} 41271294Sngie expect 0 lchown ${n1} 65534 65534 42271294Sngie for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do 43271294Sngie expect 0 lchflags ${n1} ${flag} 44271294Sngie expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP 45271294Sngie expect ${flag} lstat ${n1} flags 46271294Sngie expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP 47271294Sngie expect ${flag} lstat ${n1} flags 48271294Sngie done 49271294Sngie expect 0 lchflags ${n1} none 50271294Sngie if [ "${type}" = "dir" ]; then 51271294Sngie expect 0 rmdir ${n1} 52271294Sngie else 53271294Sngie expect 0 unlink ${n1} 54271294Sngie fi 55271294Sngiedone 56271294Sngie 57271294Sngiecd ${cdir} 58271294Sngieexpect 0 rmdir ${n0} 59