qacl: Simplify HP-UX acl_nontrivial check
authorAndreas Gruenbacher <andreas.gruenbacher@gmail.com>
Sun, 12 Apr 2015 14:36:38 +0000 (16:36 +0200)
committerPádraig Brady <P@draigBrady.com>
Wed, 15 Apr 2015 22:44:18 +0000 (23:44 +0100)
* lib/acl-internal.c: Remove struct stat parameter from HP-UX's version of
acl_nontrivial. Check if the acl has at most three entries instead (it must
have exactly three entries according to the HP-UX documentation). Ignore
uids and gids as long as an entry is either for a user (i.e., the owner),
a group (i.e., the owning group), or others.
* lib/acl-internal.h: Change HP-UX's acl_nontrivial prototype.
* lib/qcopy-acl.c (qcopy_acl): With that, we no longer need to stat the source
file.

ChangeLog
lib/acl-internal.c
lib/acl-internal.h
lib/qcopy-acl.c

index de8cc66625a9276e17813b73deb751148b455fd3..59bcf264c6653839a0fb28a37488e0d392aa860f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2015-04-15  Andreas Gruenbacher  <andreas.gruenbacher@gmail.com>
+
+       qacl: Simplify HP-UX acl_nontrivial check
+       * lib/acl-internal.c: Remove struct stat parameter from HP-UX's version of
+       acl_nontrivial. Check if the acl has at most three entries instead (it must
+       have exactly three entries according to the HP-UX documentation). Ignore
+       uids and gids as long as an entry is either for a user (i.e., the owner),
+       a group (i.e., the owning group), or others.
+       * lib/acl-internal.h: Change HP-UX's acl_nontrivial prototype.
+       * lib/qcopy-acl.c (qcopy_acl): With that, we no longer need to stat the file.
+
 2015-04-15  Andreas Gruenbacher   <andreas.gruenbacher@gmail.com>
 
        acl: On Linux, check for acls without libacl
index 7a465c1a98337c675c009d7cb8cd45de6ee1ac2d..d9bd4461ea672c929adb786c061dea1502853745 100644 (file)
@@ -336,18 +336,19 @@ acl_ace_nontrivial (int count, ace_t *entries)
 /* Return 1 if the given ACL is non-trivial.
    Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
 int
-acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb)
+acl_nontrivial (int count, struct acl_entry *entries)
 {
   int i;
 
+  if (count > 3)
+    return 1;
+
   for (i = 0; i < count; i++)
     {
       struct acl_entry *ace = &entries[i];
 
-      if (!((ace->uid == sb->st_uid && ace->gid == ACL_NSGROUP)
-            || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid)
-            || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP)))
-        return 1;
+      if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP)
+       return 1;
     }
   return 0;
 }
index 243ca32b822889f4b2ea02755cc091fd2e332576..9b9fae2e9e05f9f9a244ef2b9fad310dd14039c4 100644 (file)
@@ -220,7 +220,7 @@ extern int acl_ace_nontrivial (int count, ace_t *entries) _GL_ATTRIBUTE_PURE;
 
 /* Return 1 if the given ACL is non-trivial.
    Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-extern int acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb);
+extern int acl_nontrivial (int count, struct acl_entry *entries);
 
 #  if HAVE_ACLV_H /* HP-UX >= 11.11 */
 
index aac76a124326cfa4a79a8dabfd8965e883f7cc4c..bc258ba560bbe70eb6537c196f11b38d17134e87 100644 (file)
@@ -437,20 +437,9 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
       if (ret < 0 && saved_errno == 0)
         {
           saved_errno = errno;
-          if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
-            {
-              struct stat source_statbuf;
-
-              if ((source_desc != -1
-                   ? fstat (source_desc, &source_statbuf)
-                   : stat (src_name, &source_statbuf)) == 0)
-                {
-                  if (!acl_nontrivial (count, entries, &source_statbuf))
-                    saved_errno = 0;
-                }
-              else
-                saved_errno = errno;
-            }
+          if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP
+             && !acl_nontrivial (count, entries))
+               saved_errno = 0;
         }
       else
         did_chmod = 1;