diff options
| author | Paul Eggert | 2015-04-24 22:39:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-04-24 22:41:56 -0700 |
| commit | 27e6afeb6fe1f0b9f083fdfeacf6d69c6936a34a (patch) | |
| tree | a1bdf790a993c537044305912d3d4796789dccb0 /lib/acl-internal.c | |
| parent | 52ba851db188de47b303120df00c77e3aad7e542 (diff) | |
| download | emacs-27e6afeb6fe1f0b9f083fdfeacf6d69c6936a34a.tar.gz emacs-27e6afeb6fe1f0b9f083fdfeacf6d69c6936a34a.zip | |
Merge from gnulib
This incorporates:
2015-04-24 file-has-acl: new module, split from acl
2015-04-24 manywarnings: add GCC 5.1 warnings
2015-04-21 lstat: fix cross-compilation 'ln -s' problem
2015-04-15 qacl: Simplify HP-UX acl_nontrivial check
2015-04-15 acl: On Linux, check for acls without libacl
2015-04-14 tempname: avoid unused parameter warnings (trivial)
* lib/acl-internal.c: New file, from gnulib.
* lib/file-has-acl.c: Remove; no longer imported from gnulib.
* lib/acl-internal.h, lib/gnulib.mk, lib/qcopy-acl.c, lib/tempname.c:
* m4/acl.m4, m4/gnulib-comp.m4, m4/lstat.m4, m4/manywarnings.m4:
Update from gnulib.
Diffstat (limited to 'lib/acl-internal.c')
| -rw-r--r-- | lib/acl-internal.c | 469 |
1 files changed, 469 insertions, 0 deletions
diff --git a/lib/acl-internal.c b/lib/acl-internal.c new file mode 100644 index 00000000000..d9bd4461ea6 --- /dev/null +++ b/lib/acl-internal.c | |||
| @@ -0,0 +1,469 @@ | |||
| 1 | /* Test whether a file has a nontrivial access control list. | ||
| 2 | |||
| 3 | Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 3 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */ | ||
| 19 | |||
| 20 | #include <config.h> | ||
| 21 | |||
| 22 | #include "acl.h" | ||
| 23 | |||
| 24 | #include "acl-internal.h" | ||
| 25 | |||
| 26 | #if USE_ACL && HAVE_ACL_GET_FILE | ||
| 27 | |||
| 28 | # if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ | ||
| 29 | |||
| 30 | /* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED. | ||
| 31 | Return 1 if the given ACL is non-trivial. | ||
| 32 | Return 0 if it is trivial. */ | ||
| 33 | int | ||
| 34 | acl_extended_nontrivial (acl_t acl) | ||
| 35 | { | ||
| 36 | /* acl is non-trivial if it is non-empty. */ | ||
| 37 | return (acl_entries (acl) > 0); | ||
| 38 | } | ||
| 39 | |||
| 40 | # else /* Linux, FreeBSD, IRIX, Tru64 */ | ||
| 41 | |||
| 42 | /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS. | ||
| 43 | Return 1 if the given ACL is non-trivial. | ||
| 44 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. | ||
| 45 | Return -1 and set errno upon failure to determine it. */ | ||
| 46 | int | ||
| 47 | acl_access_nontrivial (acl_t acl) | ||
| 48 | { | ||
| 49 | /* acl is non-trivial if it has some entries other than for "user::", | ||
| 50 | "group::", and "other::". Normally these three should be present | ||
| 51 | at least, allowing us to write | ||
| 52 | return (3 < acl_entries (acl)); | ||
| 53 | but the following code is more robust. */ | ||
| 54 | # if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD */ | ||
| 55 | |||
| 56 | acl_entry_t ace; | ||
| 57 | int got_one; | ||
| 58 | |||
| 59 | for (got_one = acl_get_entry (acl, ACL_FIRST_ENTRY, &ace); | ||
| 60 | got_one > 0; | ||
| 61 | got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) | ||
| 62 | { | ||
| 63 | acl_tag_t tag; | ||
| 64 | if (acl_get_tag_type (ace, &tag) < 0) | ||
| 65 | return -1; | ||
| 66 | if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER)) | ||
| 67 | return 1; | ||
| 68 | } | ||
| 69 | return got_one; | ||
| 70 | |||
| 71 | # elif HAVE_ACL_TO_SHORT_TEXT /* IRIX */ | ||
| 72 | /* Don't use acl_get_entry: it is undocumented. */ | ||
| 73 | |||
| 74 | int count = acl->acl_cnt; | ||
| 75 | int i; | ||
| 76 | |||
| 77 | for (i = 0; i < count; i++) | ||
| 78 | { | ||
| 79 | acl_entry_t ace = &acl->acl_entry[i]; | ||
| 80 | acl_tag_t tag = ace->ae_tag; | ||
| 81 | |||
| 82 | if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ | ||
| 83 | || tag == ACL_OTHER_OBJ)) | ||
| 84 | return 1; | ||
| 85 | } | ||
| 86 | return 0; | ||
| 87 | |||
| 88 | # elif HAVE_ACL_FREE_TEXT /* Tru64 */ | ||
| 89 | /* Don't use acl_get_entry: it takes only one argument and does not work. */ | ||
| 90 | |||
| 91 | int count = acl->acl_num; | ||
| 92 | acl_entry_t ace; | ||
| 93 | |||
| 94 | for (ace = acl->acl_first; count > 0; ace = ace->next, count--) | ||
| 95 | { | ||
| 96 | acl_tag_t tag; | ||
| 97 | acl_perm_t perm; | ||
| 98 | |||
| 99 | tag = ace->entry->acl_type; | ||
| 100 | if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER)) | ||
| 101 | return 1; | ||
| 102 | |||
| 103 | perm = ace->entry->acl_perm; | ||
| 104 | /* On Tru64, perm can also contain non-standard bits such as | ||
| 105 | PERM_INSERT, PERM_DELETE, PERM_MODIFY, PERM_LOOKUP, ... */ | ||
| 106 | if ((perm & ~(ACL_READ | ACL_WRITE | ACL_EXECUTE)) != 0) | ||
| 107 | return 1; | ||
| 108 | } | ||
| 109 | return 0; | ||
| 110 | |||
| 111 | # else | ||
| 112 | |||
| 113 | errno = ENOSYS; | ||
| 114 | return -1; | ||
| 115 | # endif | ||
| 116 | } | ||
| 117 | |||
| 118 | # endif | ||
| 119 | |||
| 120 | #elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ | ||
| 121 | |||
| 122 | /* Test an ACL retrieved with GETACL. | ||
| 123 | Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. | ||
| 124 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 125 | int | ||
| 126 | acl_nontrivial (int count, aclent_t *entries) | ||
| 127 | { | ||
| 128 | int i; | ||
| 129 | |||
| 130 | for (i = 0; i < count; i++) | ||
| 131 | { | ||
| 132 | aclent_t *ace = &entries[i]; | ||
| 133 | |||
| 134 | /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). | ||
| 135 | If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). | ||
| 136 | We don't need to check ace->a_id in these cases. */ | ||
| 137 | if (!(ace->a_type == USER_OBJ | ||
| 138 | || ace->a_type == GROUP_OBJ | ||
| 139 | || ace->a_type == OTHER_OBJ | ||
| 140 | /* Note: Cygwin does not return a CLASS_OBJ ("mask:") entry | ||
| 141 | sometimes. */ | ||
| 142 | || ace->a_type == CLASS_OBJ)) | ||
| 143 | return 1; | ||
| 144 | } | ||
| 145 | return 0; | ||
| 146 | } | ||
| 147 | |||
| 148 | # ifdef ACE_GETACL | ||
| 149 | |||
| 150 | /* A shortcut for a bitmask. */ | ||
| 151 | # define NEW_ACE_WRITEA_DATA (NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA) | ||
| 152 | |||
| 153 | /* Test an ACL retrieved with ACE_GETACL. | ||
| 154 | Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. | ||
| 155 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 156 | int | ||
| 157 | acl_ace_nontrivial (int count, ace_t *entries) | ||
| 158 | { | ||
| 159 | int i; | ||
| 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 | |||
| 169 | for (i = 0; i < count; i++) | ||
| 170 | if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) | ||
| 171 | { | ||
| 172 | old_convention = 1; | ||
| 173 | break; | ||
| 174 | } | ||
| 175 | |||
| 176 | if (old_convention) | ||
| 177 | /* Running on Solaris 10. */ | ||
| 178 | for (i = 0; i < count; i++) | ||
| 179 | { | ||
| 180 | ace_t *ace = &entries[i]; | ||
| 181 | |||
| 182 | /* Note: | ||
| 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 == OLD_ALLOW | ||
| 187 | && (ace->a_flags == OLD_ACE_OWNER | ||
| 188 | || ace->a_flags == OLD_ACE_GROUP | ||
| 189 | || ace->a_flags == OLD_ACE_OTHER))) | ||
| 190 | return 1; | ||
| 191 | } | ||
| 192 | else | ||
| 193 | { | ||
| 194 | /* Running on Solaris 10 (newer version) or Solaris 11. */ | ||
| 195 | unsigned int access_masks[6] = | ||
| 196 | { | ||
| 197 | 0, /* owner@ deny */ | ||
| 198 | 0, /* owner@ allow */ | ||
| 199 | 0, /* group@ deny */ | ||
| 200 | 0, /* group@ allow */ | ||
| 201 | 0, /* everyone@ deny */ | ||
| 202 | 0 /* everyone@ allow */ | ||
| 203 | }; | ||
| 204 | |||
| 205 | for (i = 0; i < count; i++) | ||
| 206 | { | ||
| 207 | ace_t *ace = &entries[i]; | ||
| 208 | unsigned int index1; | ||
| 209 | unsigned int index2; | ||
| 210 | |||
| 211 | if (ace->a_type == NEW_ACE_ACCESS_ALLOWED_ACE_TYPE) | ||
| 212 | index1 = 1; | ||
| 213 | else if (ace->a_type == NEW_ACE_ACCESS_DENIED_ACE_TYPE) | ||
| 214 | index1 = 0; | ||
| 215 | else | ||
| 216 | return 1; | ||
| 217 | |||
| 218 | if (ace->a_flags == NEW_ACE_OWNER) | ||
| 219 | index2 = 0; | ||
| 220 | else if (ace->a_flags == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP)) | ||
| 221 | index2 = 2; | ||
| 222 | else if (ace->a_flags == NEW_ACE_EVERYONE) | ||
| 223 | index2 = 4; | ||
| 224 | else | ||
| 225 | return 1; | ||
| 226 | |||
| 227 | access_masks[index1 + index2] |= ace->a_access_mask; | ||
| 228 | } | ||
| 229 | |||
| 230 | /* The same bit shouldn't be both allowed and denied. */ | ||
| 231 | if (access_masks[0] & access_masks[1]) | ||
| 232 | return 1; | ||
| 233 | if (access_masks[2] & access_masks[3]) | ||
| 234 | return 1; | ||
| 235 | if (access_masks[4] & access_masks[5]) | ||
| 236 | return 1; | ||
| 237 | |||
| 238 | /* Check minimum masks. */ | ||
| 239 | if ((NEW_ACE_WRITE_NAMED_ATTRS | ||
| 240 | | NEW_ACE_WRITE_ATTRIBUTES | ||
| 241 | | NEW_ACE_WRITE_ACL | ||
| 242 | | NEW_ACE_WRITE_OWNER) | ||
| 243 | & ~ access_masks[1]) | ||
| 244 | return 1; | ||
| 245 | access_masks[1] &= ~(NEW_ACE_WRITE_NAMED_ATTRS | ||
| 246 | | NEW_ACE_WRITE_ATTRIBUTES | ||
| 247 | | NEW_ACE_WRITE_ACL | ||
| 248 | | NEW_ACE_WRITE_OWNER); | ||
| 249 | if ((NEW_ACE_READ_NAMED_ATTRS | ||
| 250 | | NEW_ACE_READ_ATTRIBUTES | ||
| 251 | | NEW_ACE_READ_ACL | ||
| 252 | | NEW_ACE_SYNCHRONIZE) | ||
| 253 | & ~ access_masks[5]) | ||
| 254 | return 1; | ||
| 255 | access_masks[5] &= ~(NEW_ACE_READ_NAMED_ATTRS | ||
| 256 | | NEW_ACE_READ_ATTRIBUTES | ||
| 257 | | NEW_ACE_READ_ACL | ||
| 258 | | NEW_ACE_SYNCHRONIZE); | ||
| 259 | |||
| 260 | /* Check the allowed or denied bits. */ | ||
| 261 | switch ((access_masks[0] | access_masks[1]) | ||
| 262 | & ~(NEW_ACE_READ_NAMED_ATTRS | ||
| 263 | | NEW_ACE_READ_ATTRIBUTES | ||
| 264 | | NEW_ACE_READ_ACL | ||
| 265 | | NEW_ACE_SYNCHRONIZE)) | ||
| 266 | { | ||
| 267 | case 0: | ||
| 268 | case NEW_ACE_READ_DATA: | ||
| 269 | case NEW_ACE_WRITEA_DATA: | ||
| 270 | case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA: | ||
| 271 | case NEW_ACE_EXECUTE: | ||
| 272 | case NEW_ACE_READ_DATA | NEW_ACE_EXECUTE: | ||
| 273 | case NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: | ||
| 274 | case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: | ||
| 275 | break; | ||
| 276 | default: | ||
| 277 | return 1; | ||
| 278 | } | ||
| 279 | switch ((access_masks[2] | access_masks[3]) | ||
| 280 | & ~(NEW_ACE_READ_NAMED_ATTRS | ||
| 281 | | NEW_ACE_READ_ATTRIBUTES | ||
| 282 | | NEW_ACE_READ_ACL | ||
| 283 | | NEW_ACE_SYNCHRONIZE)) | ||
| 284 | { | ||
| 285 | case 0: | ||
| 286 | case NEW_ACE_READ_DATA: | ||
| 287 | case NEW_ACE_WRITEA_DATA: | ||
| 288 | case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA: | ||
| 289 | case NEW_ACE_EXECUTE: | ||
| 290 | case NEW_ACE_READ_DATA | NEW_ACE_EXECUTE: | ||
| 291 | case NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: | ||
| 292 | case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: | ||
| 293 | break; | ||
| 294 | default: | ||
| 295 | return 1; | ||
| 296 | } | ||
| 297 | switch ((access_masks[4] | access_masks[5]) | ||
| 298 | & ~(NEW_ACE_WRITE_NAMED_ATTRS | ||
| 299 | | NEW_ACE_WRITE_ATTRIBUTES | ||
| 300 | | NEW_ACE_WRITE_ACL | ||
| 301 | | NEW_ACE_WRITE_OWNER)) | ||
| 302 | { | ||
| 303 | case 0: | ||
| 304 | case NEW_ACE_READ_DATA: | ||
| 305 | case NEW_ACE_WRITEA_DATA: | ||
| 306 | case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA: | ||
| 307 | case NEW_ACE_EXECUTE: | ||
| 308 | case NEW_ACE_READ_DATA | NEW_ACE_EXECUTE: | ||
| 309 | case NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: | ||
| 310 | case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: | ||
| 311 | break; | ||
| 312 | default: | ||
| 313 | return 1; | ||
| 314 | } | ||
| 315 | |||
| 316 | /* Check that the NEW_ACE_WRITE_DATA and NEW_ACE_APPEND_DATA bits are | ||
| 317 | either both allowed or both denied. */ | ||
| 318 | if (((access_masks[0] & NEW_ACE_WRITE_DATA) != 0) | ||
| 319 | != ((access_masks[0] & NEW_ACE_APPEND_DATA) != 0)) | ||
| 320 | return 1; | ||
| 321 | if (((access_masks[2] & NEW_ACE_WRITE_DATA) != 0) | ||
| 322 | != ((access_masks[2] & NEW_ACE_APPEND_DATA) != 0)) | ||
| 323 | return 1; | ||
| 324 | if (((access_masks[4] & NEW_ACE_WRITE_DATA) != 0) | ||
| 325 | != ((access_masks[4] & NEW_ACE_APPEND_DATA) != 0)) | ||
| 326 | return 1; | ||
| 327 | } | ||
| 328 | |||
| 329 | return 0; | ||
| 330 | } | ||
| 331 | |||
| 332 | # endif | ||
| 333 | |||
| 334 | #elif USE_ACL && HAVE_GETACL /* HP-UX */ | ||
| 335 | |||
| 336 | /* Return 1 if the given ACL is non-trivial. | ||
| 337 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 338 | int | ||
| 339 | acl_nontrivial (int count, struct acl_entry *entries) | ||
| 340 | { | ||
| 341 | int i; | ||
| 342 | |||
| 343 | if (count > 3) | ||
| 344 | return 1; | ||
| 345 | |||
| 346 | for (i = 0; i < count; i++) | ||
| 347 | { | ||
| 348 | struct acl_entry *ace = &entries[i]; | ||
| 349 | |||
| 350 | if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP) | ||
| 351 | return 1; | ||
| 352 | } | ||
| 353 | return 0; | ||
| 354 | } | ||
| 355 | |||
| 356 | # if HAVE_ACLV_H /* HP-UX >= 11.11 */ | ||
| 357 | |||
| 358 | /* Return 1 if the given ACL is non-trivial. | ||
| 359 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 360 | int | ||
| 361 | aclv_nontrivial (int count, struct acl *entries) | ||
| 362 | { | ||
| 363 | int i; | ||
| 364 | |||
| 365 | for (i = 0; i < count; i++) | ||
| 366 | { | ||
| 367 | struct acl *ace = &entries[i]; | ||
| 368 | |||
| 369 | /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). | ||
| 370 | If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). | ||
| 371 | We don't need to check ace->a_id in these cases. */ | ||
| 372 | if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */ | ||
| 373 | || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */ | ||
| 374 | || ace->a_type == CLASS_OBJ | ||
| 375 | || ace->a_type == OTHER_OBJ)) | ||
| 376 | return 1; | ||
| 377 | } | ||
| 378 | return 0; | ||
| 379 | } | ||
| 380 | |||
| 381 | # endif | ||
| 382 | |||
| 383 | #elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */ | ||
| 384 | |||
| 385 | /* Return 1 if the given ACL is non-trivial. | ||
| 386 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 387 | int | ||
| 388 | acl_nontrivial (struct acl *a) | ||
| 389 | { | ||
| 390 | /* The normal way to iterate through an ACL is like this: | ||
| 391 | struct acl_entry *ace; | ||
| 392 | for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace)) | ||
| 393 | { | ||
| 394 | struct ace_id *aei; | ||
| 395 | switch (ace->ace_type) | ||
| 396 | { | ||
| 397 | case ACC_PERMIT: | ||
| 398 | case ACC_DENY: | ||
| 399 | case ACC_SPECIFY: | ||
| 400 | ...; | ||
| 401 | } | ||
| 402 | for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei)) | ||
| 403 | ... | ||
| 404 | } | ||
| 405 | */ | ||
| 406 | return (acl_last (a) != a->acl_ext ? 1 : 0); | ||
| 407 | } | ||
| 408 | |||
| 409 | # if HAVE_ACLX_GET && defined ACL_AIX_WIP /* newer AIX */ | ||
| 410 | |||
| 411 | /* Return 1 if the given ACL is non-trivial. | ||
| 412 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 413 | int | ||
| 414 | acl_nfs4_nontrivial (nfs4_acl_int_t *a) | ||
| 415 | { | ||
| 416 | # if 1 /* let's try this first */ | ||
| 417 | return (a->aclEntryN > 0 ? 1 : 0); | ||
| 418 | # else | ||
| 419 | int count = a->aclEntryN; | ||
| 420 | int i; | ||
| 421 | |||
| 422 | for (i = 0; i < count; i++) | ||
| 423 | { | ||
| 424 | nfs4_ace_int_t *ace = &a->aclEntry[i]; | ||
| 425 | |||
| 426 | if (!((ace->flags & ACE4_ID_SPECIAL) != 0 | ||
| 427 | && (ace->aceWho.special_whoid == ACE4_WHO_OWNER | ||
| 428 | || ace->aceWho.special_whoid == ACE4_WHO_GROUP | ||
| 429 | || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE) | ||
| 430 | && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE | ||
| 431 | && ace->aceFlags == 0 | ||
| 432 | && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY | ||
| 433 | | ACE4_WRITE_DATA | ACE4_ADD_FILE | ||
| 434 | | ACE4_EXECUTE)) == 0)) | ||
| 435 | return 1; | ||
| 436 | } | ||
| 437 | return 0; | ||
| 438 | # endif | ||
| 439 | } | ||
| 440 | |||
| 441 | # endif | ||
| 442 | |||
| 443 | #elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */ | ||
| 444 | |||
| 445 | /* Test an ACL retrieved with ACL_GET. | ||
| 446 | Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. | ||
| 447 | Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | ||
| 448 | int | ||
| 449 | acl_nontrivial (int count, struct acl *entries) | ||
| 450 | { | ||
| 451 | int i; | ||
| 452 | |||
| 453 | for (i = 0; i < count; i++) | ||
| 454 | { | ||
| 455 | struct acl *ace = &entries[i]; | ||
| 456 | |||
| 457 | /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). | ||
| 458 | If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). | ||
| 459 | We don't need to check ace->a_id in these cases. */ | ||
| 460 | if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */ | ||
| 461 | || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */ | ||
| 462 | || ace->a_type == CLASS_OBJ | ||
| 463 | || ace->a_type == OTHER_OBJ)) | ||
| 464 | return 1; | ||
| 465 | } | ||
| 466 | return 0; | ||
| 467 | } | ||
| 468 | |||
| 469 | #endif | ||