{
int ret;
-#if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_SET_FILE && HAVE_ACL_FREE
+#if USE_ACL && HAVE_ACL_GET_FILE
/* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
/* Linux, FreeBSD, MacOS X, IRIX, Tru64 */
}
return 0;
-#else
-
-# if USE_ACL && defined ACL_NO_TRIVIAL
+#elif USE_ACL && defined ACL_NO_TRIVIAL
/* Solaris 10 NFSv4 ACLs. */
+
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;
-# endif
ret = qset_acl (dst_name, dest_desc, mode);
if (ret != 0)
return -1;
-# if USE_ACL && defined ACL_NO_TRIVIAL
if (aclp)
{
ret = (dest_desc < 0
}
acl_free (aclp);
}
-# endif
return 0;
+
+#else
+
+ return qset_acl (dst_name, dest_desc, mode);
+
#endif
}
int
file_has_acl (char const *name, struct stat const *sb)
{
+#if USE_ACL
if (! S_ISLNK (sb->st_mode))
{
-#if USE_ACL && HAVE_ACL_TRIVIAL
-
- /* Solaris 10, which also has NFSv4 and ZFS style ACLs. */
- return acl_trivial (name);
-
-#elif USE_ACL && HAVE_ACL && defined GETACLCNT
-
- /* Solaris 2.5 through Solaris 9, and contemporaneous versions of
- HP-UX and Unixware. */
- int n = acl (name, GETACLCNT, 0, NULL);
- return n < 0 ? (errno == ENOSYS ? 0 : -1) : (MIN_ACL_ENTRIES < n);
-
-#elif USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_FREE
+# if HAVE_ACL_GET_FILE
/* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
/* Linux, FreeBSD, MacOS X, IRIX, Tru64 */
if (ret < 0)
return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1;
return ret;
-#endif
+
+# elif HAVE_ACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */
+
+# if HAVE_ACL_TRIVIAL
+
+ /* Solaris 10, which also has NFSv4 and ZFS style ACLs. */
+ return acl_trivial (name);
+
+# 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. */
+ int n = acl (name, GETACLCNT, 0, NULL);
+ return n < 0 ? (errno == ENOSYS ? 0 : -1) : (MIN_ACL_ENTRIES < n);
+
+# endif
+
+# endif
}
+#endif
/* FIXME: Add support for AIX, Irix, and Tru64. Please see Samba's
source/lib/sysacls.c file for fix-related ideas. */
qset_acl (char const *name, int desc, mode_t mode)
{
#if USE_ACL
-# if MODE_INSIDE_ACL
-# if HAVE_ACL_SET_FILE && HAVE_ACL_FREE
+# if HAVE_ACL_GET_FILE
/* POSIX 1003.1e draft 17 (abandoned) specific version. */
+ /* Linux, FreeBSD, MacOS X, IRIX, Tru64 */
+# if MODE_INSIDE_ACL
/* Linux, FreeBSD, IRIX, Tru64 */
/* We must also have acl_from_text and acl_delete_def_file.
}
return 0;
-# elif defined ACL_NO_TRIVIAL
- /* Solaris 10, with NFSv4 ACLs. */
- acl_t *aclp;
- char acl_text[] = "user::---,group::---,mask:---,other:---";
-
- 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;
- }
- else
- {
- int acl_result = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp));
- int acl_errno = errno;
- acl_free (aclp);
- if (acl_result == 0 || acl_errno != ENOSYS)
- {
- errno = acl_errno;
- return acl_result;
- }
- }
-
- return chmod_or_fchmod (name, desc, mode);
-
-# else /* Unknown flavor of ACLs */
- return chmod_or_fchmod (name, desc, mode);
-# endif
-# else /* !MODE_INSIDE_ACL */
-# if HAVE_ACL_SET_FILE && HAVE_ACL_FREE
- /* POSIX 1003.1e draft 17 (abandoned) specific version. */
+# else /* !MODE_INSIDE_ACL */
/* MacOS X */
acl_t acl;
}
}
- return chmod_or_fchmod (name, desc, mode);
-# else /* Unknown flavor of ACLs */
return chmod_or_fchmod (name, desc, mode);
# endif
+
+# elif defined ACL_NO_TRIVIAL
+ /* Solaris 10, with NFSv4 ACLs. */
+ acl_t *aclp;
+ char acl_text[] = "user::---,group::---,mask:---,other:---";
+
+ 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;
+ }
+ else
+ {
+ int acl_result = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp));
+ int acl_errno = errno;
+ acl_free (aclp);
+ if (acl_result == 0 || acl_errno != ENOSYS)
+ {
+ errno = acl_errno;
+ return acl_result;
+ }
+ }
+
+ return chmod_or_fchmod (name, desc, mode);
+
+# else /* Unknown flavor of ACLs */
+ return chmod_or_fchmod (name, desc, mode);
# endif
#else /* !USE_ACL */
return chmod_or_fchmod (name, desc, mode);