From: Bruno Haible Date: Mon, 5 Sep 2011 22:26:07 +0000 (+0200) Subject: acl: Clean up Solaris code. X-Git-Tag: v0.1~1954 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=1b73d49853abed4f7750f87c8a141cd24e9c388e;p=gnulib.git acl: Clean up Solaris code. * lib/acl-internal.h: Remove no-op #if. * lib/file-has-acl.c: Likewise. * lib/set-mode-acl.c (qset_acl): Remove unused Solaris code. * lib/copy-acl.c (qcopy_acl): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 58c8a0e69..cb4433962 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2011-09-05 Bruno Haible + acl: Clean up Solaris code. + * lib/acl-internal.h: Remove no-op #if. + * lib/file-has-acl.c: Likewise. + * lib/set-mode-acl.c (qset_acl): Remove unused Solaris code. + * lib/copy-acl.c (qcopy_acl): Likewise. + +2011-09-05 Bruno Haible + acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version) in binaries built on the original Solaris 10. * lib/file-has-acl.c (file_has_acl): ACLs with 4..6 ACEs can be diff --git a/lib/acl-internal.h b/lib/acl-internal.h index 00b50022f..aade05570 100644 --- a/lib/acl-internal.h +++ b/lib/acl-internal.h @@ -183,14 +183,10 @@ extern int acl_access_nontrivial (acl_t); # define MODE_INSIDE_ACL 1 # endif -# if !(defined ACL_NO_TRIVIAL && 0) /* Solaris <= 10, Cygwin */ - /* 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); -# endif - # ifdef ACE_GETACL /* Solaris 10 */ /* Test an ACL retrieved with ACE_GETACL. diff --git a/lib/copy-acl.c b/lib/copy-acl.c index c46fbda35..030c4bfc9 100644 --- a/lib/copy-acl.c +++ b/lib/copy-acl.c @@ -181,57 +181,20 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, #elif USE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ -# if defined ACL_NO_TRIVIAL && 0 - /* Solaris 10 (newer version), which has additional API declared in - (acl_t) and implemented in libsec (acl_set, acl_trivial, - acl_fromtext, ...). */ - - int ret; - acl_t *aclp = NULL; - ret = (source_desc < 0 - ? acl_get (src_name, ACL_NO_TRIVIAL, &aclp) - : facl_get (source_desc, ACL_NO_TRIVIAL, &aclp)); - if (ret != 0 && errno != ENOSYS) - return -2; - - ret = qset_acl (dst_name, dest_desc, mode); - if (ret != 0) - return -1; - - if (aclp) - { - ret = (dest_desc < 0 - ? acl_set (dst_name, aclp) - : facl_set (dest_desc, aclp)); - if (ret != 0) - { - int saved_errno = errno; - - acl_free (aclp); - errno = saved_errno; - return -1; - } - acl_free (aclp); - } - - return 0; - -# else /* Solaris, Cygwin, general case */ - /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions of Unixware. The acl() call returns the access and default ACL both at once. */ -# ifdef ACE_GETACL +# ifdef ACE_GETACL int ace_count; ace_t *ace_entries; -# endif +# endif int count; aclent_t *entries; int did_chmod; int saved_errno; int ret; -# ifdef ACE_GETACL +# ifdef ACE_GETACL /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4 file systems (whereas the other ones are used in UFS file systems). There is an API @@ -284,7 +247,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, /* Huh? The number of ACL entries changed since the last call. Repeat. */ } -# endif +# endif for (;;) { @@ -327,9 +290,9 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, } /* Is there an ACL of either kind? */ -# ifdef ACE_GETACL +# ifdef ACE_GETACL if (ace_count == 0) -# endif +# endif if (count == 0) return qset_acl (dst_name, dest_desc, mode); @@ -367,7 +330,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, } free (entries); -# ifdef ACE_GETACL +# ifdef ACE_GETACL if (ace_count > 0) { ret = (dest_desc != -1 @@ -382,7 +345,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, } } free (ace_entries); -# endif +# endif if (MODE_INSIDE_ACL && did_chmod <= ((mode & (S_ISUID | S_ISGID | S_ISVTX)) ? 1 : 0)) @@ -404,8 +367,6 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, } return 0; -# endif - #elif USE_ACL && HAVE_GETACL /* HP-UX */ int count; diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index d063e925e..6fd9c25b6 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -120,8 +120,6 @@ acl_access_nontrivial (acl_t acl) #elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ -# if !(defined ACL_NO_TRIVIAL && 0) /* Solaris <= 10, Cygwin */ - /* Test an ACL retrieved with GETACL. Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ @@ -148,7 +146,7 @@ acl_nontrivial (int count, aclent_t *entries) return 0; } -# ifdef ACE_GETACL +# ifdef ACE_GETACL /* Test an ACL retrieved with ACE_GETACL. Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. @@ -300,8 +298,6 @@ acl_ace_nontrivial (int count, ace_t *entries) return 0; } -# endif - # endif #elif USE_ACL && HAVE_GETACL /* HP-UX */ diff --git a/lib/set-mode-acl.c b/lib/set-mode-acl.c index be5592b38..7e12d571e 100644 --- a/lib/set-mode-acl.c +++ b/lib/set-mode-acl.c @@ -203,56 +203,9 @@ qset_acl (char const *name, int desc, mode_t mode) # elif HAVE_FACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */ -# if defined ACL_NO_TRIVIAL && 0 - /* Solaris 10 (newer version), which has additional API declared in - (acl_t) and implemented in libsec (acl_set, acl_trivial, - acl_fromtext, ...). */ - - acl_t *aclp; - char acl_text[] = "user::---,group::---,mask:---,other:---"; - int ret; - int saved_errno; - - if (mode & S_IRUSR) acl_text[ 6] = 'r'; - if (mode & S_IWUSR) acl_text[ 7] = 'w'; - if (mode & S_IXUSR) acl_text[ 8] = 'x'; - if (mode & S_IRGRP) acl_text[17] = acl_text[26] = 'r'; - if (mode & S_IWGRP) acl_text[18] = acl_text[27] = 'w'; - if (mode & S_IXGRP) acl_text[19] = acl_text[28] = 'x'; - if (mode & S_IROTH) acl_text[36] = 'r'; - if (mode & S_IWOTH) acl_text[37] = 'w'; - if (mode & S_IXOTH) acl_text[38] = 'x'; - - if (acl_fromtext (acl_text, &aclp) != 0) - { - errno = ENOMEM; - return -1; - } - - ret = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp)); - saved_errno = errno; - acl_free (aclp); - if (ret < 0) - { - if (saved_errno == ENOSYS || saved_errno == EOPNOTSUPP) - return chmod_or_fchmod (name, desc, mode); - errno = saved_errno; - return -1; - } - - if (mode & (S_ISUID | S_ISGID | S_ISVTX)) - { - /* We did not call chmod so far, so the special bits have not yet - been set. */ - return chmod_or_fchmod (name, desc, mode); - } - return 0; - -# else /* Solaris, Cygwin, general case */ - int done_setacl = 0; -# ifdef ACE_GETACL +# ifdef ACE_GETACL /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4 file systems (whereas the other ones are used in UFS file systems). */ @@ -419,7 +372,7 @@ qset_acl (char const *name, int desc, mode_t mode) if (ret == 0) done_setacl = 1; } -# endif +# endif if (!done_setacl) { @@ -458,8 +411,6 @@ qset_acl (char const *name, int desc, mode_t mode) } return 0; -# endif - # elif HAVE_GETACL /* HP-UX */ struct stat statbuf;