xref: /freebsd/contrib/pjdfstest/tests/chflags/07.t (revision 531c2d7af3cd2e64eec94aa1b19c4b2f16fce515)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require chflags
11
12echo "1..93"
13
14n0=`namegen`
15n1=`namegen`
16n2=`namegen`
17
18expect 0 mkdir ${n0} 0755
19cdir=`pwd`
20cd ${n0}
21
22for type in regular dir fifo block char socket symlink; do
23	if [ "${type}" != "symlink" ]; then
24		create_file ${type} ${n1}
25		expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
26		expect none stat ${n1} flags
27		expect 0 chown ${n1} 65534 65534
28		expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
29		expect none stat ${n1} flags
30		if [ "${type}" = "dir" ]; then
31			expect 0 rmdir ${n1}
32		else
33			expect 0 unlink ${n1}
34		fi
35	fi
36
37	create_file ${type} ${n1}
38	expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
39	expect none lstat ${n1} flags
40	expect 0 lchown ${n1} 65534 65534
41	expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
42	expect none lstat ${n1} flags
43	if [ "${type}" = "dir" ]; then
44		expect 0 rmdir ${n1}
45	else
46		expect 0 unlink ${n1}
47	fi
48done
49
50cd ${cdir}
51expect 0 rmdir ${n0}
52