bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] qcopy-acl: port to Fedora 9


From: Paul Eggert
Subject: [PATCH] qcopy-acl: port to Fedora 9
Date: Tue, 17 Jan 2023 15:23:46 -0800

It has libattr-2.4.41, which is too old for our code.
Problem reported by Po Lu <https://bugs.gnu.org/60843>.
* m4/xattr.m4 (gl_FUNC_XATTR): Check that we can use
ATTR_ACTION_PERMISSIONS, too.  Refactor so that there’s a single
test program that we compile and link, rather than doing the tests
in dribs and drabs.
---
 ChangeLog   | 10 ++++++++++
 m4/xattr.m4 | 42 ++++++++++++++++++++++++++----------------
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 111c957c1e..79e9da5d22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-01-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       qcopy-acl: port to Fedora 9
+       It has libattr-2.4.41, which is too old for our code.
+       Problem reported by Po Lu <https://bugs.gnu.org/60843>.
+       * m4/xattr.m4 (gl_FUNC_XATTR): Check that we can use
+       ATTR_ACTION_PERMISSIONS, too.  Refactor so that there’s a single
+       test program that we compile and link, rather than doing the tests
+       in dribs and drabs.
+
 2023-01-17  Bruno Haible  <bruno@clisp.org>
 
        execute tests: Avoid test failure with GNU make 4.4.
diff --git a/m4/xattr.m4 b/m4/xattr.m4
index 6141515652..0e179cc0d1 100644
--- a/m4/xattr.m4
+++ b/m4/xattr.m4
@@ -1,5 +1,5 @@
 # xattr.m4 - check for Extended Attributes (Linux)
-# serial 5
+# serial 6
 
 # Copyright (C) 2003-2023 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -17,23 +17,33 @@ AC_DEFUN([gl_FUNC_XATTR],
   AC_SUBST([LIB_XATTR])
 
   if test "$use_xattr" = yes; then
-    AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
-    use_xattr=no
-    if test "$ac_cv_header_attr_libattr_h" = yes \
-        && test "$ac_cv_header_attr_error_context_h" = yes; then
-      xattr_saved_LIBS=$LIBS
-      AC_SEARCH_LIBS([attr_copy_file], [attr],
-                     [test "$ac_cv_search_attr_copy_file" = "none required" ||
-                        LIB_XATTR="$ac_cv_search_attr_copy_file"])
-      AC_CHECK_FUNCS([attr_copy_file])
-      LIBS=$xattr_saved_LIBS
-      if test "$ac_cv_func_attr_copy_file" = yes; then
-        use_xattr=yes
-      fi
-    fi
-    if test $use_xattr = no; then
+    AC_CACHE_CHECK([for xattr library with ATTR_ACTION_PERMISSIONS],
+      [gl_cv_xattr_lib],
+      [gl_cv_xattr_lib=no
+       AC_LANG_CONFTEST(
+         [AC_LANG_PROGRAM(
+            [[#include <attr/error_context.h>
+              #include <attr/libattr.h>
+              static int
+              is_attr_permissions (const char *name, struct error_context *ctx)
+              {
+                return attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS;
+              }
+            ]],
+            [[return attr_copy_fd ("/", 0, "/", 0, is_attr_permissions, 0);
+            ]])])
+       AC_LINK_IFELSE([],
+         [gl_cv_xattr_lib='none required'],
+         [xattr_saved_LIBS=$LIBS
+          LIBS="-lattr $LIBS"
+          AC_LINK_IFELSE([], [gl_cv_xattr_lib=-lattr])
+          LIBS=$xattr_saved_LIBS])])
+    if test "$gl_cv_xattr_lib" = no; then
       AC_MSG_WARN([libattr development library was not found or not usable.])
       AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
+      use_xattr=no
+    elif test "$gl_cv_xattr_lib" != 'none required'; then
+      LIB_XATTR=$gl_cv_xattr_lib
     fi
   fi
   if test "$use_xattr" = yes; then
-- 
2.39.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]