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