]> Savannah Git Hosting - gnulib.git/commitdiff
file-has-acl: Fix compilation errors on macOS et al. (regr. 2024-11-09).
authorBruno Haible <bruno@clisp.org>
Mon, 11 Nov 2024 06:25:00 +0000 (07:25 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 11 Nov 2024 06:25:00 +0000 (07:25 +0100)
* m4/acl.m4 (gl_FUNC_ACL): Test whether acl_get_link_np exists.
* lib/file-has-acl.c (file_has_aclinfo): Use ACL_SYMLINK_FOLLOW, not
AC_SYMLINK_FOLLOW. Don't use acl_get_link_np if this function does not
exist.

ChangeLog
lib/file-has-acl.c
m4/acl.m4

index 095333f6fe111d9b37aeaa8e091c91111e831f41..c3e7a2ab0e60804e33f5280759d2c9cbb6749a7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-11  Bruno Haible  <bruno@clisp.org>
+
+       file-has-acl: Fix compilation errors on macOS et al. (regr. 2024-11-09).
+       * m4/acl.m4 (gl_FUNC_ACL): Test whether acl_get_link_np exists.
+       * lib/file-has-acl.c (file_has_aclinfo): Use ACL_SYMLINK_FOLLOW, not
+       AC_SYMLINK_FOLLOW. Don't use acl_get_link_np if this function does not
+       exist.
+
 2024-11-10  Bruno Haible  <bruno@clisp.org>
 
        relocatable-prog-wrapper: Fix compilation error on NetBSD 7.
index 468ac36f8b56dc96f2c4df429e8fb0a2bb3ee808..7e05d39131d0bb0c59e9eb467069e6b32400d517 100644 (file)
@@ -393,7 +393,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name,
 
   {
     /* POSIX 1003.1e (draft 17 -- abandoned) specific version.  */
-    /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
+    /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
     int ret;
 
 #   if HAVE_ACL_EXTENDED_FILE /* Linux */
@@ -410,7 +410,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name,
        always return NULL / EINVAL.  There is no point in making
        these two useless calls.  The real ACL is retrieved through
        acl_get_file (name, ACL_TYPE_EXTENDED).  */
-    acl_t acl = ((flags & AC_SYMLINK_FOLLOW
+    acl_t acl = ((flags & ACL_SYMLINK_FOLLOW
                   ? acl_get_file
                   : acl_get_link_np)
                  (name, ACL_TYPE_EXTENDED));
@@ -421,11 +421,14 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name,
       }
     else
       ret = -1;
-#   else /* FreeBSD, IRIX, Tru64, Cygwin >= 2.5 */
-    acl_t acl = ((flags & AC_SYMLINK_FOLLOW
-                  ? acl_get_file
-                  : acl_get_link_np)
-                 (name, ACL_TYPE_ACCESS));
+#   else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */
+    acl_t acl;
+#    if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10 */
+    if (!(flags & ACL_SYMLINK_FOLLOW))
+      acl = acl_get_link_np (name, ACL_TYPE_ACCESS);
+    else
+#    endif
+      acl = acl_get_file (name, ACL_TYPE_ACCESS);
     if (acl)
       {
         ret = acl_access_nontrivial (acl);
@@ -436,8 +439,9 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name,
         /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always
            returns NULL with errno not set.  There is no point in
            making this call.  */
-#    else /* FreeBSD, IRIX, Cygwin >= 2.5 */
-        /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS)
+#    else /* FreeBSD, NetBSD >= 10, IRIX, Cygwin >= 2.5 */
+        /* On Linux, FreeBSD, NetBSD, IRIX,
+               acl_get_file (name, ACL_TYPE_ACCESS)
            and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory
            either both succeed or both fail; it depends on the
            file system.  Therefore there is no point in making the second
index 3e8d8219d191f2464f13d58457d42b3a035c9647..68d7799b66815a1c6adabf449f6d8fedff64440e 100644 (file)
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,5 +1,5 @@
 # acl.m4
-# serial 33
+# serial 34
 dnl Copyright (C) 2002, 2004-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,8 +34,8 @@ AC_DEFUN_ONCE([gl_FUNC_ACL],
     if test $ac_cv_header_sys_acl_h = yes; then
       gl_saved_LIBS=$LIBS
 
-      dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, Mac OS X,
-      dnl IRIX, Tru64, Cygwin >= 2.5).
+      dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, NetBSD >= 10,
+      dnl Mac OS X, IRIX, Tru64, Cygwin >= 2.5).
       dnl -lacl is needed on GNU/Linux, -lpacl on OSF/1.
       if test $use_acl = 0; then
         AC_SEARCH_LIBS([acl_get_file], [acl pacl],
@@ -44,6 +44,7 @@ AC_DEFUN_ONCE([gl_FUNC_ACL],
            fi
            AC_CHECK_FUNCS(
              [acl_get_file acl_get_fd acl_set_file acl_set_fd \
+              acl_get_link_np \
               acl_free acl_from_mode acl_from_text \
               acl_delete_def_file acl_extended_file \
               acl_delete_fd_np acl_delete_file_np \