4 desc
="chmod changes permission"
9 if supported lchmod
; then
19 expect
0 mkdir
${n2} 0755
23 expect
0 create
${n0} 0644
24 expect
0644 stat
${n0} mode
25 expect
0 chmod ${n0} 0111
26 expect
0111 stat
${n0} mode
29 expect
0 mkdir
${n0} 0755
30 expect
0755 stat
${n0} mode
31 expect
0 chmod ${n0} 0753
32 expect
0753 stat
${n0} mode
35 expect
0 mkfifo ${n0} 0644
36 expect
0644 stat
${n0} mode
37 expect
0 chmod ${n0} 0310
38 expect
0310 stat
${n0} mode
41 expect
0 create
${n0} 0644
42 expect
0 symlink
${n0} ${n1}
43 expect
0644 stat
${n1} mode
44 expect
0 chmod ${n1} 0321
45 expect
0321 stat
${n1} mode
46 expect
0321 lstat
${n0} mode
50 if supported lchmod
; then
51 expect
0 create
${n0} 0644
52 expect
0 symlink
${n0} ${n1}
53 expect
0644 stat
${n1} mode
54 expect
0 lchmod
${n1} 0321
55 expect
0321 lstat
${n1} mode
56 expect
0 lchmod
${n1} 0531
57 expect
0531 lstat
${n1} mode
58 expect
0644 stat
${n0} mode
59 expect
0644 stat
${n1} mode
64 # successful chmod(2) updates ctime.
65 expect
0 create
${n0} 0644
66 ctime1
=`${fstest} stat ${n0} ctime`
68 expect
0 chmod ${n0} 0111
69 ctime2
=`${fstest} stat ${n0} ctime`
70 test_check
$ctime1 -lt $ctime2
73 expect
0 mkdir
${n0} 0755
74 ctime1
=`${fstest} stat ${n0} ctime`
76 expect
0 chmod ${n0} 0753
77 ctime2
=`${fstest} stat ${n0} ctime`
78 test_check
$ctime1 -lt $ctime2
81 expect
0 mkfifo ${n0} 0644
82 ctime1
=`${fstest} stat ${n0} ctime`
84 expect
0 chmod ${n0} 0310
85 ctime2
=`${fstest} stat ${n0} ctime`
86 test_check
$ctime1 -lt $ctime2
89 if supported lchmod
; then
90 expect
0 symlink
${n1} ${n0}
91 ctime1
=`${fstest} lstat ${n0} ctime`
93 expect
0 lchmod
${n0} 0321
94 ctime2
=`${fstest} lstat ${n0} ctime`
95 test_check
$ctime1 -lt $ctime2
99 # unsuccessful chmod(2) does not update ctime.
100 expect
0 create
${n0} 0644
101 ctime1
=`${fstest} stat ${n0} ctime`
103 expect EPERM
-u 65534 chmod ${n0} 0111
104 ctime2
=`${fstest} stat ${n0} ctime`
105 test_check
$ctime1 -eq $ctime2
106 expect
0 unlink
${n0}
108 expect
0 mkdir
${n0} 0755
109 ctime1
=`${fstest} stat ${n0} ctime`
111 expect EPERM
-u 65534 chmod ${n0} 0753
112 ctime2
=`${fstest} stat ${n0} ctime`
113 test_check
$ctime1 -eq $ctime2
116 expect
0 mkfifo ${n0} 0644
117 ctime1
=`${fstest} stat ${n0} ctime`
119 expect EPERM
-u 65534 chmod ${n0} 0310
120 ctime2
=`${fstest} stat ${n0} ctime`
121 test_check
$ctime1 -eq $ctime2
122 expect
0 unlink
${n0}
124 if supported lchmod
; then
125 expect
0 symlink
${n1} ${n0}
126 ctime1
=`${fstest} lstat ${n0} ctime`
128 expect EPERM
-u 65534 lchmod
${n0} 0321
129 ctime2
=`${fstest} lstat ${n0} ctime`
130 test_check
$ctime1 -eq $ctime2
131 expect
0 unlink
${n0}
134 # POSIX: If the calling process does not have appropriate privileges, and if
135 # the group ID of the file does not match the effective group ID or one of the
136 # supplementary group IDs and if the file is a regular file, bit S_ISGID
137 # (set-group-ID on execution) in the file's mode shall be cleared upon
138 # successful return from chmod().
140 expect
0 create
${n0} 0755
141 expect
0 chown
${n0} 65535 65535
142 expect
0 -u 65535 -g 65535 chmod ${n0} 02755
143 expect
02755 stat
${n0} mode
144 expect
0 -u 65535 -g 65535 chmod ${n0} 0755
145 expect
0755 stat
${n0} mode
147 # Unfortunately FreeBSD doesn't clear set-gid bit, but returns EPERM instead.
150 expect EPERM
-u 65535 -g 65534 chmod ${n0} 02755
151 expect
0755 stat
${n0} mode
154 expect
0 -u 65535 -g 65534 chmod ${n0} 02755
155 expect
0755 stat
${n0} mode
158 expect
0 unlink
${n0}