[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
acl: #ifology
From: |
Bruno Haible |
Subject: |
acl: #ifology |
Date: |
Wed, 4 Jun 2008 00:09:52 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Jim,
Did you have time to look at
<http://lists.gnu.org/archive/html/bug-gnulib/2008-06/msg00038.html> ?
In the meantime, before I continue with MacOS X and Solaris support, a bit
of #ifology:
- Always use the same conditionals to detect POSIX-draft-like API,
not HAVE_ACL_GET_FILE here and HAVE_ACL_SET_FILE there. I have no doubt
about the equivalence. (See the file doc/acl-resources.txt.)
- After all, I find it better to have the #if MODE_INSIDE_ACL a secondary
#if, while the primary #if is about the platform API.
- In file-has-acl.c there if no need to test if the file is a link if
then no code is executed at all (if !USE_ACL).
Also the comments were wrong, saying that HP-UX has the same API as Solaris
(it has 'acl' function, like Solaris, but with a different prototype) and that
Solaris 10 has the acl_trivial function (not true in the Solaris 10 version
I have access to).
This one I commit, since I don't expect objections.
2008-06-03 Bruno Haible <address@hidden>
* lib/file-has-acl.c (file_has_acl): Put Solaris 10 code after POSIX-
draft code. Simplify #ifs.
* lib/set-mode-acl.c (qset_acl): Don't test for symlink if !USE_ACL.
Put Solaris code after POSIX-draft code. Fix comments regarding
Solaris 10, HP-UX. Mention Cygwin.
* lib/copy-acl.c (qcopy_acl): Simplify #ifs.
--- lib/copy-acl.c.orig 2008-06-03 23:59:52.000000000 +0200
+++ lib/copy-acl.c 2008-06-03 23:39:47.000000000 +0200
@@ -41,7 +41,7 @@
{
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 */
@@ -125,23 +125,20 @@
}
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
@@ -157,9 +154,13 @@
}
acl_free (aclp);
}
-# endif
return 0;
+
+#else
+
+ return qset_acl (dst_name, dest_desc, mode);
+
#endif
}
--- lib/file-has-acl.c.orig 2008-06-03 23:59:52.000000000 +0200
+++ lib/file-has-acl.c 2008-06-03 23:53:40.000000000 +0200
@@ -30,21 +30,10 @@
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 */
@@ -77,8 +66,27 @@
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. */
--- lib/set-mode-acl.c.orig 2008-06-03 23:59:52.000000000 +0200
+++ lib/set-mode-acl.c 2008-06-03 23:45:20.000000000 +0200
@@ -49,9 +49,10 @@
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.
@@ -138,46 +139,7 @@
}
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;
@@ -223,9 +185,44 @@
}
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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- acl: #ifology,
Bruno Haible <=