]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/pjdfstest/tests/chmod/08.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / pjdfstest / tests / chmod / 08.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="chmod returns EPERM if the named file has its immutable or append-only flag set"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 require chflags
10
11 case "${os}:${fs}" in
12 FreeBSD:ZFS)
13         echo "1..29"
14         ;;
15 FreeBSD:UFS)
16         echo "1..54"
17         ;;
18 *)
19         quick_exit
20 esac
21
22 n0=`namegen`
23
24 expect 0 create ${n0} 0644
25 expect 0 chflags ${n0} SF_IMMUTABLE
26 expect EPERM chmod ${n0} 0600
27 supported lchmod && expect EPERM lchmod ${n0} 0600
28 expect 0644 stat ${n0} mode
29 expect 0 chflags ${n0} none
30 expect 0 chmod ${n0} 0600
31 expect 0600 stat ${n0} mode
32 supported lchmod && expect 0 lchmod ${n0} 0400
33 supported lchmod && expect 0400 stat ${n0} mode
34 expect 0 unlink ${n0}
35
36 expect 0 create ${n0} 0644
37 expect 0 chflags ${n0} SF_NOUNLINK
38 expect 0 chmod ${n0} 0600
39 expect 0600 stat ${n0} mode
40 supported lchmod && expect 0 lchmod ${n0} 0400
41 supported lchmod && expect 0400 stat ${n0} mode
42 expect 0 chflags ${n0} none
43 expect 0 unlink ${n0}
44
45 case "${os}:${fs}" in
46 FreeBSD: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         ;;
58 FreeBSD: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         ;;
98 esac