X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ffile-has-acl.c;h=3d4d5c16ff0a27807903962edc40e6670918715d;hb=b344de996cd51f8a2f2558a3172016b64d99c622;hp=a815e4c47deb6f07b52be898b36cc5cf1e0f7e1e;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index a815e4c47..3d4d5c16f 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -234,6 +234,33 @@ acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb) return 0; } +# if HAVE_ACLV_H /* HP-UX >= 11.11 */ + +/* Return 1 if the given ACL is non-trivial. + Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ +int +aclv_nontrivial (int count, struct acl *entries) +{ + int i; + + for (i = 0; i < count; i++) + { + struct acl *ace = &entries[i]; + + /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). + If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). + We don't need to check ace->a_id in these cases. */ + if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */ + || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */ + || ace->a_type == CLASS_OBJ + || ace->a_type == OTHER_OBJ)) + return 1; + } + return 0; +} + +# endif + #elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */ /* Return 1 if the given ACL is non-trivial. @@ -519,15 +546,23 @@ file_has_acl (char const *name, struct stat const *sb) # elif HAVE_GETACL /* HP-UX */ - int count; - struct acl_entry entries[NACLENTRIES]; - for (;;) { + int count; + struct acl_entry entries[NACLENTRIES]; + count = getacl (name, 0, NULL); if (count < 0) - return (errno == ENOSYS || errno == EOPNOTSUPP ? 0 : -1); + { + /* ENOSYS is seen on newer HP-UX versions. + EOPNOTSUPP is typically seen on NFS mounts. + ENOTSUP was seen on Quantum StorNext file systems (cvfs). */ + if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) + break; + else + return -1; + } if (count == 0) return 0; @@ -555,6 +590,46 @@ file_has_acl (char const *name, struct stat const *sb) Repeat. */ } +# if HAVE_ACLV_H /* HP-UX >= 11.11 */ + + for (;;) + { + int count; + struct acl entries[NACLVENTRIES]; + + count = acl ((char *) name, ACL_CNT, NACLVENTRIES, entries); + + if (count < 0) + { + /* EOPNOTSUPP is seen on NFS in HP-UX 11.11, 11.23. + EINVAL is seen on NFS in HP-UX 11.31. */ + if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) + break; + else + return -1; + } + + if (count == 0) + return 0; + + if (count > NACLVENTRIES) + /* If NACLVENTRIES cannot be trusted, use dynamic memory + allocation. */ + abort (); + + /* If there are more than 4 entries, there cannot be only the + four base ACL entries. */ + if (count > 4) + return 1; + + if (acl ((char *) name, ACL_GET, count, entries) == count) + return aclv_nontrivial (count, entries); + /* Huh? The number of ACL entries changed since the last call. + Repeat. */ + } + +# endif + # elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ acl_type_t type;