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