summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-04-26 09:20:34 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-04-26 09:21:05 -0700
commitff714c0a2094bdefd9ed41603493e66aaf285f12 (patch)
treefe2e17c0b0cde95dcab84e3487db1aef42c03012
parent496c2cf0347839dc189891d7f158fcdd7f5c2e7c (diff)
downloadgnulib-ff714c0a2094bdefd9ed41603493e66aaf285f12.tar.gz
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.
-rw-r--r--ChangeLog13
-rw-r--r--lib/file-has-acl.c7
-rw-r--r--m4/acl.m424
3 files changed, 34 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index eb1110be8a..0c87783608 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2015-04-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ 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 <P@draigBrady.com>
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 d2b6a146fa..7e26c53c15 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 <sys/xattr.h>
-#endif
-
-#if HAVE_LINUX_XATTR_H
# include <linux/xattr.h>
#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 186353c395..b8f4660f7e 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 <sys/types.h>
+ #include <sys/xattr.h>
+ #include <linux/xattr.h>
+ ]],
+ [[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.