comparison lib/file-has-acl.c @ 10191:ccfd3047da72

Work around the Solaris 10 ACE ACLs ABI change.
author Bruno Haible <bruno@clisp.org>
date Tue, 10 Jun 2008 02:40:28 +0200
parents 22b6b32738ea
children 03ef9ae804c9
comparison
equal deleted inserted replaced
10190:e33912e3fd26 10191:ccfd3047da72
117 117
118 # endif 118 # endif
119 119
120 120
121 #elif USE_ACL && HAVE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ 121 #elif USE_ACL && HAVE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
122
123 # if !defined ACL_NO_TRIVIAL /* Solaris <= 10, Cygwin */
122 124
123 /* Test an ACL retrieved with GETACL. 125 /* Test an ACL retrieved with GETACL.
124 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. 126 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
125 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ 127 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
126 int 128 int
144 return 1; 146 return 1;
145 } 147 }
146 return 0; 148 return 0;
147 } 149 }
148 150
149 # if defined ACE_GETACL && defined ALLOW && defined ACE_OWNER 151 # ifdef ACE_GETACL
150 152
151 /* Test an ACL retrieved with ACE_GETACL. 153 /* Test an ACL retrieved with ACE_GETACL.
152 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. 154 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
153 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ 155 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
154 int 156 int
155 acl_ace_nontrivial (int count, ace_t *entries) 157 acl_ace_nontrivial (int count, ace_t *entries)
156 { 158 {
157 int i; 159 int i;
158 160
161 /* The flags in the ace_t structure changed in a binary incompatible way
162 when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15.
163 How to distinguish the two conventions at runtime?
164 In the old convention, usually three ACEs have a_flags = ACE_OWNER /
165 ACE_GROUP / ACE_OTHER, in the range 0x0100..0x0400. In the new
166 convention, these values are not used. */
167 int old_convention = 0;
168
159 for (i = 0; i < count; i++) 169 for (i = 0; i < count; i++)
160 { 170 if (entries[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_OTHER))
161 ace_t *ace = &entries[i]; 171 {
162 172 old_convention = 1;
163 /* Note: If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from 173 break;
164 stat(). If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from 174 }
165 stat(). We don't need to check ace->a_who in these cases. */ 175
166 if (!(ace->a_type == ALLOW 176 if (old_convention)
167 && (ace->a_flags == ACE_OWNER 177 /* Running on Solaris 10. */
168 || ace->a_flags == ACE_GROUP 178 for (i = 0; i < count; i++)
169 || ace->a_flags == ACE_OTHER))) 179 {
170 return 1; 180 ace_t *ace = &entries[i];
171 } 181
172 return 0; 182 /* Note:
173 } 183 If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from stat().
184 If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from stat().
185 We don't need to check ace->a_who in these cases. */
186 if (!(ace->a_type == ALLOW
187 && (ace->a_flags == ACE_OWNER
188 || ace->a_flags == ACE_GROUP
189 || ace->a_flags == ACE_OTHER)))
190 return 1;
191 }
192 else
193 /* Running on Solaris 10 (newer version) or Solaris 11. */
194 for (i = 0; i < count; i++)
195 {
196 ace_t *ace = &entries[i];
197
198 if (!(ace->a_type == ACE_ACCESS_ALLOWED_ACE_TYPE
199 && (ace->a_flags == NEW_ACE_OWNER
200 || ace->a_flags
201 == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP)
202 || ace->a_flags == ACE_EVERYONE)
203 && (ace->a_access_mask
204 & ~(NEW_ACE_READ_DATA | NEW_ACE_WRITE_DATA | NEW_ACE_EXECUTE))
205 == 0))
206 return 1;
207 }
208
209 return 0;
210 }
211
212 # endif
174 213
175 # endif 214 # endif
176 215
177 #elif USE_ACL && HAVE_GETACL /* HP-UX */ 216 #elif USE_ACL && HAVE_GETACL /* HP-UX */
178 217
308 return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1; 347 return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1;
309 return ret; 348 return ret;
310 349
311 # elif HAVE_ACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */ 350 # elif HAVE_ACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */
312 351
313 # if HAVE_ACL_TRIVIAL 352 # if defined ACL_NO_TRIVIAL
314 353
315 /* Solaris 10 (newer version), which has additional API declared in 354 /* Solaris 10 (newer version), which has additional API declared in
316 <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial, 355 <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial,
317 acl_fromtext, ...). */ 356 acl_fromtext, ...). */
318 return acl_trivial (name); 357 return acl_trivial (name);