2015-04-26 20:06 GMT+02:00 Tom G. Christensen <t...@jupiterrise.com>:
> On 26/04/15 18:22, Paul Eggert wrote:
>>
>> Thanks for reporting that.  I installed the attached patch, which should
>> fix it.
>
>
> Confirmed, thanks.

I would rather have gnulib define XATTR_NAME_POSIX_ACL_ACCESS and
XATTR_NAME_POSIX_ACL_DEFAULT when the kernel headers don't provide
them: Checking for richacls also requires getxattr, and the combined
test doesn't help there at all.

I have updated my changes to include that:

  https://github.com/andreas-gruenbacher/gnulib
  https://github.com/andreas-gruenbacher/coreutils


By the way, this part of commit "file-has-acl: new module, split from
acl" in m4/acl.m4 is a bit strange:

>    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.
>    gl_need_lib_has_acl=1
>    LIB_HAS_ACL=$LIB_ACL

Function gl_FILE_HAS_ACL depends on gl_FUNC_ACL to be called
afterwards, and gl_FUNC_ACL does get called through the gnulib module
dependencies. Now why is LIB_HAS_ACL being set in both functions?

Thanks,
Andreas
commit 43026d7249810e4c3b26f642140868d733e21ed5
Author: Andreas Gruenbacher <andreas.gruenbac...@gmail.com>
Date:   Tue Apr 28 12:01:19 2015 +0200

    file-has-acl: Split feature tests again
    
    * lib/file-has-acl.c: Instead of testing for
    XATTR_NAME_POSIX_ACL_ACCESS and XATTR_NAME_POSIX_ACL_DEFAULT,
    define them when needed.
    * m4/acl.m4 (gl_FILE_HAS_ACL): With that, Paul's
    GETXATTR_WITH_POSIX_ACLS change shouldn't be needed anymore.

diff --git a/ChangeLog b/ChangeLog
index fcc6383..0d9474d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-04-28  Andreas Gruenbacher  <agrue...@redhat.com>
+
+       file-has-acl: Split feature tests again
+       * lib/file-has-acl.c: Instead of testing for
+       XATTR_NAME_POSIX_ACL_ACCESS and XATTR_NAME_POSIX_ACL_DEFAULT,
+       define them when needed.
+       * m4/acl.m4 (gl_FILE_HAS_ACL): With that, Paul's
+       GETXATTR_WITH_POSIX_ACLS change shouldn't be needed anymore.
+
 2015-04-27  Paul Eggert  <egg...@cs.ucla.edu>
 
        tests: pacify GCC 5.1's stricter printf checking
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 7e26c53..e187117 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -29,8 +29,11 @@
 
 #include "acl-internal.h"
 
-#if GETXATTR_WITH_POSIX_ACLS
+#if HAVE_SYS_XATTR_H
 # include <sys/xattr.h>
+#endif
+
+#if HAVE_LINUX_XATTR_H
 # include <linux/xattr.h>
 #endif
 
@@ -48,7 +51,15 @@ file_has_acl (char const *name, struct stat const *sb)
   if (! S_ISLNK (sb->st_mode))
     {
 
-# if GETXATTR_WITH_POSIX_ACLS
+# if HAVE_GETXATTR
+
+#  ifndef XATTR_NAME_POSIX_ACL_ACCESS
+#   define XATTR_NAME_POSIX_ACL_ACCESS "system.posix_acl_access"
+#  endif
+
+#  ifndef XATTR_NAME_POSIX_ACL_DEFAULT
+#   define XATTR_NAME_POSIX_ACL_DEFAULT "system.posix_acl_default"
+#  endif
 
       ssize_t ret;
 
diff --git a/m4/acl.m4 b/m4/acl.m4
index b8f4660..bf2e30b 100644
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,5 +1,5 @@
 # acl.m4 - check for access control list (ACL) primitives
-# serial 19
+# serial 20
 
 # Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -181,26 +181,12 @@ AC_DEFUN([gl_FILE_HAS_ACL],
 [
   AC_REQUIRE([gl_FUNC_ACL_ARG])
   if test "$enable_acl" != no; then
-    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])])
+    AC_CHECK_HEADERS([linux/xattr.h])
+    AC_CHECK_HEADERS([sys/xattr.h],
+      [AC_CHECK_FUNCS_ONCE([getxattr])])
   fi
-  if test "$gl_cv_getxattr_with_posix_acls" = yes; then
+  if test "$ac_cv_header_sys_xattr_h,$ac_cv_func_getxattr" = yes,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.

Reply via email to