]> Savannah Git Hosting - gnulib.git/commitdiff
file-has-acl: fix build on Mac OS X 10
authorPádraig Brady <P@draigBrady.com>
Mon, 1 Jun 2015 23:53:48 +0000 (00:53 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 2 Jun 2015 00:12:34 +0000 (01:12 +0100)
This reverts commit f1b37e3a which doesn't work on Mac OS X >= 10.4
which has an incompatible 6 parameter getxattr() call.

* doc/glibc-functions/getxattr.texi: Mention the divergent getxattr()
call on Mac OS X >= 10.4.
* doc/glibc-functions/fgetxattr.texi: Likewise.
* lib/file-has-acl.c: Revert to more complete combined check.
* m4/acl.m4 (gl_FILE_HAS_ACL): Likewise.
Reported by Jack Howarth.

ChangeLog
doc/glibc-functions/fgetxattr.texi
doc/glibc-functions/getxattr.texi
lib/file-has-acl.c
m4/acl.m4

index 25dec08b771011e6a5f5aae70fe364773340fcdb..2b922ceb6c1fdf944ceb1bafa066a51646ba63f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2015-06-02  Pádraig Brady  <P@draigBrady.com>
+
+       file-has-acl: fix build on Mac OS X 10
+       This reverts commit f1b37e3a which doesn't work on Mac OS X >= 10.4
+       which has an incompatible 6 parameter getxattr() call.
+       * doc/glibc-functions/getxattr.texi: Mention the divergent getxattr()
+       call on Mac OS X >= 10.4.
+       * doc/glibc-functions/fgetxattr.texi: Likewise.
+       * lib/file-has-acl.c: Revert to more complete combined check.
+       * m4/acl.m4 (gl_FILE_HAS_ACL): Likewise.
+       Reported by Jack Howarth.
+
 2015-06-02  Pádraig Brady  <P@draigBrady.com>
 
        prefix-gnulib-mk: remove no longer needed special case
index 0fc9bac36aff283f503609aece579fe05049d074..0fb458f347686b6c54c1ceae93147d1c5b1548ff 100644 (file)
@@ -14,4 +14,7 @@ Portability problems not fixed by Gnulib:
 This function is missing on many non-glibc platforms:
 Mac OS X 10.3, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11,
 IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5, BeOS.
+@item
+This function has extra @code{offset} and @code{options} parameters:
+Mac OS X 10.4
 @end itemize
index f206d25332c26ddcac07b392a3548cf004984b9b..51ac784a660bdfb56f817bf8b37293defe031d6a 100644 (file)
@@ -14,4 +14,7 @@ Portability problems not fixed by Gnulib:
 This function is missing on many non-glibc platforms:
 Mac OS X 10.3, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11,
 IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5, BeOS.
+@item
+This function has extra @code{offset} and @code{options} parameters:
+Mac OS X 10.4
 @end itemize
index e1871176c03a78b12fa2e823e33e7a6c6f7cf33c..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,15 +48,7 @@ file_has_acl (char const *name, struct stat const *sb)
   if (! S_ISLNK (sb->st_mode))
     {
 
-# 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
+# if GETXATTR_WITH_POSIX_ACLS
 
       ssize_t ret;
 
index 5da6a43ab6ac5c0f3f7537ecabe36304243fb67e..75fc9ce4c03d95c30a3ec2e404b4c945a2a8fc69 100644 (file)
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,5 +1,5 @@
 # acl.m4 - check for access control list (ACL) primitives
-# serial 20
+# serial 21
 
 # 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_func_getxattr" = 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.