changeset 10177:caed32fb1892

New function acl_extended_nontrivial (MacOS X only).
author Bruno Haible <bruno@clisp.org>
date Sun, 08 Jun 2008 13:58:26 +0200
parents 43bafd6ea0d8
children b8de08146b0d
files ChangeLog lib/acl-internal.h lib/copy-acl.c lib/file-has-acl.c
diffstat 4 files changed, 33 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jun 08 13:29:35 2008 +0200
+++ b/ChangeLog	Sun Jun 08 13:58:26 2008 +0200
@@ -1,3 +1,12 @@
+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.
--- a/lib/acl-internal.h	Sun Jun 08 13:29:35 2008 +0200
+++ b/lib/acl-internal.h	Sun Jun 08 13:58:26 2008 +0200
@@ -145,11 +145,18 @@
 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
 
--- a/lib/copy-acl.c	Sun Jun 08 13:29:35 2008 +0200
+++ b/lib/copy-acl.c	Sun Jun 08 13:58:26 2008 +0200
@@ -155,7 +155,7 @@
     {
       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);
--- a/lib/file-has-acl.c	Sun Jun 08 13:29:35 2008 +0200
+++ b/lib/file-has-acl.c	Sun Jun 08 13:58:26 2008 +0200
@@ -26,6 +26,20 @@
 
 #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 @@
 
 #   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 @@
 	  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