New function acl_extended_nontrivial (MacOS X only).
authorBruno Haible <bruno@clisp.org>
Sun, 8 Jun 2008 11:58:26 +0000 (13:58 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 8 Jun 2008 11:58:26 +0000 (13:58 +0200)
ChangeLog
lib/acl-internal.h
lib/copy-acl.c
lib/file-has-acl.c

index 982f89a..48407ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-06-08  Bruno Haible  <bruno@clisp.org>
 
+       * lib/acl-internal.h (acl_extended_nontrivial) [MacOS X]: New
+       declaration.
+       * lib/file-has-acl.c (acl_extended_nontrivial) [MacOS X]: New function.
+       (acl_access_nontrivial): Remove MacOS X case.
+       (file_has_acl): Use acl_extended_nontrivial.
+       * lib/copy-acl.c (qcopy_acl): Likewise.
+
+2008-06-08  Bruno Haible  <bruno@clisp.org>
+
        * lib/set-mode-acl.c (qset_acl): Trivial code simplifications.
 
 2008-06-08  Jim Meyering  <meyering@redhat.com>
index 664cd5b..d92cd4b 100644 (file)
@@ -145,11 +145,18 @@ rpl_acl_set_fd (int fd, acl_t acl)
 extern int acl_entries (acl_t);
 #  endif
 
+#  if HAVE_ACL_TYPE_EXTENDED /* MacOS X */
+/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
+   Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial.  */
+extern int acl_extended_nontrivial (acl_t);
+#  else
 /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS.
    Return 1 if the given ACL is non-trivial.
    Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.
    Return -1 and set errno upon failure to determine it.  */
 extern int acl_access_nontrivial (acl_t);
+#  endif
 
 # endif
 
index 87952f4..b6e1ce2 100644 (file)
@@ -155,7 +155,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
     {
       int saved_errno = errno;
 
-      if (ACL_NOT_WELL_SUPPORTED (errno) && !(acl_entries (acl) > 0))
+      if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_extended_nontrivial (acl))
         {
          acl_free (acl);
          return chmod_or_fchmod (dst_name, dest_desc, mode);
index 15cce4f..9bae202 100644 (file)
 
 #if USE_ACL && HAVE_ACL_GET_FILE
 
+# if HAVE_ACL_TYPE_EXTENDED /* MacOS X */
+
+/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
+   Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial.  */
+int
+acl_extended_nontrivial (acl_t acl)
+{
+  /* acl is non-trivial if it is non-empty.  */
+  return (acl_entries (acl) > 0);
+}
+
+# else /* Linux, FreeBSD, IRIX, Tru64 */
+
 /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS.
    Return 1 if the given ACL is non-trivial.
    Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.
@@ -33,7 +47,6 @@
 int
 acl_access_nontrivial (acl_t acl)
 {
-# if MODE_INSIDE_ACL /* Linux, FreeBSD, IRIX, Tru64 */
   /* acl is non-trivial if it has some entries other than for "user::",
      "group::", and "other::".  Normally these three should be present
      at least, allowing us to write
@@ -100,12 +113,9 @@ acl_access_nontrivial (acl_t acl)
 
 #   endif
 #  endif
-# else /* MacOS X */
+}
 
-  /* acl is non-trivial if it is non-empty.  */
-  return (acl_entries (acl) > 0);
 # endif
-}
 
 #endif
 
@@ -144,7 +154,7 @@ file_has_acl (char const *name, struct stat const *sb)
          acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED);
          if (acl)
            {
-             ret = (0 < acl_entries (acl));
+             ret = acl_extended_nontrivial (acl);
              acl_free (acl);
            }
          else