xref: /freebsd/contrib/pjdfstest/tests/chown/08.t (revision 02e9120893770924227138ba49df1edb3896112a)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/08.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="chown returns EPERM if the named file has its immutable or append-only flag set"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require chflags
11
12case "${os}:${fs}" in
13FreeBSD:ZFS)
14	echo "1..20"
15	;;
16FreeBSD:UFS)
17	echo "1..44"
18	;;
19*)
20	quick_exit
21esac
22
23n0=`namegen`
24
25expect 0 create ${n0} 0644
26expect 0 chflags ${n0} SF_IMMUTABLE
27expect EPERM chown ${n0} 65534 65534
28expect 0,0 stat ${n0} uid,gid
29expect 0 chflags ${n0} none
30expect 0 chown ${n0} 65534 65534
31expect 65534,65534 stat ${n0} uid,gid
32expect 0 unlink ${n0}
33
34expect 0 create ${n0} 0644
35expect 0 chflags ${n0} SF_NOUNLINK
36expect 0 chown ${n0} 65534 65534
37expect 65534,65534 stat ${n0} uid,gid
38expect 0 chflags ${n0} none
39expect 0 unlink ${n0}
40
41case "${os}:${fs}" in
42FreeBSD:ZFS)
43	expect 0 create ${n0} 0644
44	expect 0 chflags ${n0} SF_APPEND
45	expect 0 chown ${n0} 65534 65534
46	expect 65534,65534 stat ${n0} uid,gid
47	expect 0 chflags ${n0} none
48	expect 0 unlink ${n0}
49	;;
50FreeBSD:UFS)
51	expect 0 create ${n0} 0644
52	expect 0 chflags ${n0} SF_APPEND
53	expect EPERM chown ${n0} 65534 65534
54	expect 0,0 stat ${n0} uid,gid
55	expect 0 chflags ${n0} none
56	expect 0 chown ${n0} 65534 65534
57	expect 65534,65534 stat ${n0} uid,gid
58	expect 0 unlink ${n0}
59
60	expect 0 create ${n0} 0644
61	expect 0 chflags ${n0} UF_IMMUTABLE
62	expect EPERM chown ${n0} 65534 65534
63	expect 0,0 stat ${n0} uid,gid
64	expect 0 chflags ${n0} none
65	expect 0 chown ${n0} 65534 65534
66	expect 65534,65534 stat ${n0} uid,gid
67	expect 0 unlink ${n0}
68
69	expect 0 create ${n0} 0644
70	expect 0 chflags ${n0} UF_NOUNLINK
71	expect 0 chown ${n0} 65534 65534
72	expect 65534,65534 stat ${n0} uid,gid
73	expect 0 chflags ${n0} none
74	expect 0 unlink ${n0}
75
76	expect 0 create ${n0} 0644
77	expect 0 chflags ${n0} UF_APPEND
78	expect EPERM chown ${n0} 65534 65534
79	expect 0,0 stat ${n0} uid,gid
80	expect 0 chflags ${n0} none
81	expect 0 chown ${n0} 65534 65534
82	expect 65534,65534 stat ${n0} uid,gid
83	expect 0 unlink ${n0}
84	;;
85esac
86