2 # vim: filetype=sh noexpandtab ts=8 sw=8
3 # $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $
5 desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user"
18 expect 0 mkdir ${n0} 0755
22 for type in regular dir fifo block char socket symlink; do
23 if [ "${type}" != "symlink" ]; then
24 create_file ${type} ${n1}
25 expect 0 chown ${n1} 65534 65534
26 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
27 expect 0 chflags ${n1} ${flag}
28 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
29 expect ${flag} stat ${n1} flags
30 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
31 expect ${flag} stat ${n1} flags
33 expect 0 chflags ${n1} none
34 if [ "${type}" = "dir" ]; then
41 create_file ${type} ${n1}
42 expect 0 lchown ${n1} 65534 65534
43 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
44 expect 0 lchflags ${n1} ${flag}
45 expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
46 expect ${flag} lstat ${n1} flags
47 expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
48 expect ${flag} lstat ${n1} flags
50 expect 0 lchflags ${n1} none
51 if [ "${type}" = "dir" ]; then