]> Savannah Git Hosting - gnulib.git/commitdiff
file-has-acl: port to CentOS 6
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Apr 2015 16:20:34 +0000 (09:20 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Apr 2015 16:21:05 +0000 (09:21 -0700)
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
lib/file-has-acl.c
m4/acl.m4

index eb1110be8aa71d6701b2125fb1f5a82b2622a3f1..0c87783608cd37def6521c3ce693b38a73c0e7f8 100644 (file)
--- 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
index d2b6a146fa224152c396293d7ee8dc0f58429570..7e26c53c158911544f22c85829934b932a982bf8 100644 (file)
 
 #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;
 
index 186353c395b634a268e6b9779b175fdfc2594830..b8f4660f7e3d48c06c7b669509b4d78b7c815c6a 100644 (file)
--- 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.