>From fc35d110d1bd3ddd4baffdf7a9f8368fec34b542 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 26 Apr 2015 09:20:34 -0700 Subject: [PATCH] file-has-acl: port to CentOS 6 Problem reported by Tom G. Christensen in: http://lists.gnu.org/archive/html/bug-gnulib/2015-04/msg00074.html * lib/file-has-acl.c: Use GETXATTR_WITH_POSIX_ACLS instead of a combination of HAVE_SYS_XATTR_H, HAVE_LINUX_XATTR_H, and HAVE_GETXATTR. * m4/acl.m4 (gl_FILE_HAS_ACL): Test fot the entire combination of linux/xattr.h, sys/xattr.h, getxattr, XATTR_NAME_POSIX_ACL_ACCESS, and XATTR_NAME_POSIX_ACL_DEFAULT, since that's what what file-has-acl.c actually needs. --- ChangeLog | 13 +++++++++++++ lib/file-has-acl.c | 7 ++----- m4/acl.m4 | 24 +++++++++++++++++++----- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb1110b..0c87783 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2015-04-26 Paul Eggert + + file-has-acl: port to CentOS 6 + Problem reported by Tom G. Christensen in: + http://lists.gnu.org/archive/html/bug-gnulib/2015-04/msg00074.html + * lib/file-has-acl.c: Use GETXATTR_WITH_POSIX_ACLS instead of a + combination of HAVE_SYS_XATTR_H, HAVE_LINUX_XATTR_H, and + HAVE_GETXATTR. + * m4/acl.m4 (gl_FILE_HAS_ACL): Test fot the entire combination of + linux/xattr.h, sys/xattr.h, getxattr, XATTR_NAME_POSIX_ACL_ACCESS, + and XATTR_NAME_POSIX_ACL_DEFAULT, since that's what what + file-has-acl.c actually needs. + 2015-04-26 Pádraig Brady file-has-acl: always return false when ACLs aren't supported diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index d2b6a14..7e26c53 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -29,11 +29,8 @@ #include "acl-internal.h" -#if HAVE_SYS_XATTR_H +#if GETXATTR_WITH_POSIX_ACLS # include -#endif - -#if HAVE_LINUX_XATTR_H # include #endif @@ -51,7 +48,7 @@ file_has_acl (char const *name, struct stat const *sb) if (! S_ISLNK (sb->st_mode)) { -# if HAVE_GETXATTR && defined XATTR_NAME_POSIX_ACL_ACCESS && defined XATTR_NAME_POSIX_ACL_DEFAULT +# if GETXATTR_WITH_POSIX_ACLS ssize_t ret; diff --git a/m4/acl.m4 b/m4/acl.m4 index 186353c..b8f4660 100644 --- a/m4/acl.m4 +++ b/m4/acl.m4 @@ -1,5 +1,5 @@ # acl.m4 - check for access control list (ACL) primitives -# serial 18 +# serial 19 # Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -181,12 +181,26 @@ AC_DEFUN([gl_FILE_HAS_ACL], [ AC_REQUIRE([gl_FUNC_ACL_ARG]) if test "$enable_acl" != no; then - AC_CHECK_HEADERS([linux/xattr.h], - [AC_CHECK_HEADERS([sys/xattr.h], - [AC_CHECK_FUNCS([getxattr])])]) + AC_CACHE_CHECK([for getxattr with XATTR_NAME_POSIX_ACL macros], + [gl_cv_getxattr_with_posix_acls], + [gl_cv_getxattr_with_posix_acls=no + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + ]], + [[ssize_t a = getxattr (".", XATTR_NAME_POSIX_ACL_ACCESS, 0, 0); + ssize_t b = getxattr (".", XATTR_NAME_POSIX_ACL_DEFAULT, 0, 0); + return a < 0 || b < 0; + ]])], + [gl_cv_getxattr_with_posix_acls=yes])]) fi - if test "$ac_cv_header_sys_xattr_h,$ac_cv_header_linux_xattr_h,$ac_cv_func_getxattr" = yes,yes,yes; then + if test "$gl_cv_getxattr_with_posix_acls" = yes; then LIB_HAS_ACL= + AC_DEFINE([GETXATTR_WITH_POSIX_ACLS], 1, + [Define to 1 if getxattr works with XATTR_NAME_POSIX_ACL_ACCESS + and XATTR_NAME_POSIX_ACL_DEFAULT.]) else dnl Set gl_need_lib_has_acl to a nonempty value, so that any dnl later gl_FUNC_ACL call will set LIB_HAS_ACL=$LIB_ACL. -- 2.1.0