From: Bruno Haible Date: Sun, 8 Jun 2008 11:58:26 +0000 (+0200) Subject: New function acl_extended_nontrivial (MacOS X only). X-Git-Tag: v0.1~7293 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=feea4bcda87c7fe24c41b77f2f3f453c842bf617;p=gnulib.git New function acl_extended_nontrivial (MacOS X only). --- diff --git a/ChangeLog b/ChangeLog index 982f89a2e..48407ef29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2008-06-08 Bruno Haible + * 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 + * lib/set-mode-acl.c (qset_acl): Trivial code simplifications. 2008-06-08 Jim Meyering diff --git a/lib/acl-internal.h b/lib/acl-internal.h index 664cd5bc9..d92cd4b44 100644 --- a/lib/acl-internal.h +++ b/lib/acl-internal.h @@ -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 diff --git a/lib/copy-acl.c b/lib/copy-acl.c index 87952f408..b6e1ce22f 100644 --- a/lib/copy-acl.c +++ b/lib/copy-acl.c @@ -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); diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 15cce4f3d..9bae202f1 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -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 @@ 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