Add support for Cygwin ACLs.
authorBruno Haible <bruno@clisp.org>
Sun, 8 Jun 2008 14:52:23 +0000 (16:52 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 8 Jun 2008 14:52:23 +0000 (16:52 +0200)
ChangeLog
lib/acl-internal.h
lib/copy-acl.c
lib/set-mode-acl.c

index a8a464f747662e81e14c2a576ac74ccf956698ff..9ff15ce1c2ee2568215febaa881bfadd8e6d6177 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-08  Bruno Haible  <bruno@clisp.org>
+
+       Add support for Cygwin ACLs.
+       * lib/acl-internal.h (MODE_INSIDE_ACL): New macro for Solaris-like API.
+       * lib/set-mode-acl.c (qset_acl) [!MODE_INSIDE_ACL]: Don't optimize away
+       the chmod_or_fchmod call.
+       * lib/copy-acl.c (qcopy_acl) [!MODE_INSIDE_ACL]: Likewise.
+
 2008-06-08  Bruno Haible  <bruno@clisp.org>
 
        Fix bug with setuid modes in Solaris 10+ code.
index 0ecd22f7e8df6e0e863c73c21952e4e8a0facefd..f629eeb1f1812d7c391aadc94a3c361ecc07d41b 100644 (file)
@@ -160,6 +160,14 @@ extern int acl_access_nontrivial (acl_t);
 
 # elif HAVE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
 
+/* Set to 1 if a file's mode is implicit by the ACL.
+   Set to 0 if a file's mode is stored independently from the ACL.  */
+#  if defined __CYGWIN__ /* Cygwin */
+#   define MODE_INSIDE_ACL 0
+#  else /* Solaris */
+#   define MODE_INSIDE_ACL 1
+#  endif
+
 /* 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, aclent_t *entries);
index 34f02923a4f6f4cfea8fcc5b3c53e1251a149019..d20fa04bb11735cd817d8542d10dcc6f57e518c0 100644 (file)
@@ -330,8 +330,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
     if (count == 0)
       return qset_acl (dst_name, dest_desc, mode);
 
-  did_chmod = 0; /* set to 1 once the mode bits in 0777 have been set,
-                   set to 2 once the mode bits other than 0777 have been set */
+  did_chmod = 0; /* set to 1 once the mode bits in 0777 have been set */
   saved_errno = 0; /* the first non-ignorable error code */
 
   /* If both ace_entries and entries are available, try SETACL before
@@ -371,7 +370,8 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
   free (ace_entries);
 #  endif
 
-  if (did_chmod <= ((mode & (S_ISUID | S_ISGID | S_ISVTX)) ? 1 : 0))
+  if (!MODE_INSIDE_ACL
+      || did_chmod <= ((mode & (S_ISUID | S_ISGID | S_ISVTX)) ? 1 : 0))
     {
       /* We did not call chmod so far, and either the mode and the ACL are
         separate or special bits are to be set which don't fit into ACLs.  */
index 0a7fa73ce8b12a7a881a58d013132b515e077815..b5b14ad4d07e25bd94259dc87e482ee517c646bc 100644 (file)
@@ -305,7 +305,7 @@ qset_acl (char const *name, int desc, mode_t mode)
       }
   }
   
-  if (mode & (S_ISUID | S_ISGID | S_ISVTX))
+  if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX)))
     {
       /* We did not call chmod so far, so the special bits have not yet
          been set.  */