4 desc="chmod changes permission"
9 if supported lchmod; then
19 expect 0 mkdir ${n2} 0755
23 for type in regular dir fifo block char socket symlink; do
24 if [ "${type}" != "symlink" ]; then
25 create_file ${type} ${n0}
26 expect 0 chmod ${n0} 0111
27 expect 0111 stat ${n0} mode
29 expect 0 symlink ${n0} ${n1}
30 mode=`${fstest} lstat ${n1} mode`
31 expect 0 chmod ${n1} 0222
32 expect 0222 stat ${n1} mode
33 expect 0222 stat ${n0} mode
34 expect ${mode} lstat ${n1} mode
37 if [ "${type}" = "dir" ]; then
44 if supported lchmod; then
45 create_file ${type} ${n0}
46 expect 0 lchmod ${n0} 0111
47 expect 0111 lstat ${n0} mode
48 if [ "${type}" = "dir" ]; then
56 # successful chmod(2) updates ctime.
57 for type in regular dir fifo block char socket symlink; do
58 if [ "${type}" != "symlink" ]; then
59 create_file ${type} ${n0}
60 ctime1=`${fstest} stat ${n0} ctime`
62 expect 0 chmod ${n0} 0111
63 ctime2=`${fstest} stat ${n0} ctime`
64 test_check $ctime1 -lt $ctime2
65 if [ "${type}" = "dir" ]; then
72 if supported lchmod; then
73 create_file ${type} ${n0}
74 ctime1=`${fstest} lstat ${n0} ctime`
76 expect 0 lchmod ${n0} 0111
77 ctime2=`${fstest} lstat ${n0} ctime`
78 test_check $ctime1 -lt $ctime2
79 if [ "${type}" = "dir" ]; then
87 # unsuccessful chmod(2) does not update ctime.
88 for type in regular dir fifo block char socket symlink; do
89 if [ "${type}" != "symlink" ]; then
90 create_file ${type} ${n0}
91 ctime1=`${fstest} stat ${n0} ctime`
93 expect EPERM -u 65534 chmod ${n0} 0111
94 ctime2=`${fstest} stat ${n0} ctime`
95 test_check $ctime1 -eq $ctime2
96 if [ "${type}" = "dir" ]; then
103 if supported lchmod; then
104 create_file ${type} ${n0}
105 ctime1=`${fstest} lstat ${n0} ctime`
107 expect EPERM -u 65534 lchmod ${n0} 0321
108 ctime2=`${fstest} lstat ${n0} ctime`
109 test_check $ctime1 -eq $ctime2
110 if [ "${type}" = "dir" ]; then
113 expect 0 unlink ${n0}
118 # POSIX: If the calling process does not have appropriate privileges, and if
119 # the group ID of the file does not match the effective group ID or one of the
120 # supplementary group IDs and if the file is a regular file, bit S_ISGID
121 # (set-group-ID on execution) in the file's mode shall be cleared upon
122 # successful return from chmod().
124 expect 0 create ${n0} 0755
125 expect 0 chown ${n0} 65535 65535
126 expect 0 -u 65535 -g 65535 chmod ${n0} 02755
127 expect 02755 stat ${n0} mode
128 expect 0 -u 65535 -g 65535 chmod ${n0} 0755
129 expect 0755 stat ${n0} mode
131 todo FreeBSD "S_ISGID should be removed and chmod(2) should success and FreeBSD returns EPERM."
132 expect 0 -u 65535 -g 65534 chmod ${n0} 02755
133 expect 0755 stat ${n0} mode
135 expect 0 unlink ${n0}