From: Bruno Haible Date: Mon, 11 Nov 2024 06:25:00 +0000 (+0100) Subject: file-has-acl: Fix compilation errors on macOS et al. (regr. 2024-11-09). X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c56c270c03eede5a3342e323f0469d5fdbc09cf0;p=gnulib.git 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/ChangeLog b/ChangeLog index 095333f6fe..c3e7a2ab0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-11-11 Bruno Haible + + 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 relocatable-prog-wrapper: Fix compilation error on NetBSD 7. 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 \