Paul Eggert wrote: > + When ! (flags & AC_SYMLINK_FOLLOW), prefer acl_get_link_np to > + acl_get_file on platforms that have both APIs,
This patch leads to compilation errors on macOS, FreeBSD, NetBSD, Cygwin: ../../gllib/file-has-acl.c:425:27: error: use of undeclared identifier 'AC_SYMLINK_FOLLOW'; did you mean 'ACL_SYMLINK_FOLLOW'? acl_t acl = ((flags & AC_SYMLINK_FOLLOW ^~~~~~~~~~~~~~~~~ ACL_SYMLINK_FOLLOW ../../gllib/acl.h:37:8: note: 'ACL_SYMLINK_FOLLOW' declared here enum { ACL_SYMLINK_FOLLOW = 0x10000 }; ^ On Cygwin also: ../../gllib/file-has-acl.c:427:21: error: 'acl_get_link_np' undeclared (first use in this function) 427 | : acl_get_link_np) | ^~~~~~~~~~~~~~~ This patch fixes it. 2024-11-11 Bruno Haible <br...@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. diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 468ac36f8b..7e05d39131 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -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 diff --git a/m4/acl.m4 b/m4/acl.m4 index 3e8d8219d1..68d7799b66 100644 --- 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 \