* lib/qcopy-acl.c: Include <string.h>, <linux/xattr.h>.
(XATTR_NAME_NFSV4_ACL, XATTR_NAME_POSIX_ACL_ACCESS,
XATTR_NAME_POSIX_ACL_DEFAULT): New macros, from file-has-acl.c.
(is_attr_permissions): Test for these names explicitly.
* m4/acl.m4 (gl_QCOPY_ACL): New macro.
* modules/qcopy-acl (Files): Add m4/acl.m4.
(configure.ac): Invoke gl_QCOPY_ACL.
+2024-07-15 Bruno Haible <bruno@clisp.org>
+
+ qcopy-acl: Fix copying of ACLs on CentOS 7 (regression 2023-01-12).
+ * lib/qcopy-acl.c: Include <string.h>, <linux/xattr.h>.
+ (XATTR_NAME_NFSV4_ACL, XATTR_NAME_POSIX_ACL_ACCESS,
+ XATTR_NAME_POSIX_ACL_DEFAULT): New macros, from file-has-acl.c.
+ (is_attr_permissions): Test for these names explicitly.
+ * m4/acl.m4 (gl_QCOPY_ACL): New macro.
+ * modules/qcopy-acl (Files): Add m4/acl.m4.
+ (configure.ac): Invoke gl_QCOPY_ACL.
+
2024-07-14 Bruno Haible <bruno@clisp.org>
stdlib: Avoid syntax errors in libstdc++ header files.
#if USE_XATTR
# include <attr/libattr.h>
+# include <string.h>
+
+# if HAVE_LINUX_XATTR_H
+# include <linux/xattr.h>
+# endif
+# ifndef XATTR_NAME_NFSV4_ACL
+# define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
+# endif
+# 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
/* Returns 1 if NAME is the name of an extended attribute that is related
to permissions, i.e. ACLs. Returns 0 otherwise. */
static int
is_attr_permissions (const char *name, struct error_context *ctx)
{
- return attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS;
+ /* We need to explicitly test for the known extended attribute names,
+ because at least on CentOS 7, attr_copy_action does not do it. */
+ return strcmp (name, XATTR_NAME_POSIX_ACL_ACCESS) == 0
+ || strcmp (name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0
+ || strcmp (name, XATTR_NAME_NFSV4_ACL) == 0
+ || attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS;
}
#endif /* USE_XATTR */
# acl.m4
-# serial 30
+# serial 31
dnl Copyright (C) 2002, 2004-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AS_IF([test "$gl_cv_func_working_acl_get_file" != no], [$1], [$2])
])
-# On GNU/Linux, testing if a file has an acl can be done with the
-# listxattr and getxattr syscalls, which don't require linking
-# against additional libraries. Assume this works if linux/attr.h
-# and listxattr are present.
+# Prerequisites of module file-has-acl.
AC_DEFUN([gl_FILE_HAS_ACL],
[
AC_REQUIRE([gl_FUNC_ACL_ARG])
+ # On GNU/Linux, testing if a file has an acl can be done with the
+ # listxattr and getxattr syscalls, which don't require linking
+ # against additional libraries. Assume this works if linux/attr.h
+ # and listxattr are present.
AC_CHECK_HEADERS_ONCE([linux/xattr.h])
AC_CHECK_FUNCS_ONCE([listxattr])
FILE_HAS_ACL_LIB=
FILE_HAS_ACL_LIB=$LIB_ACL])
AC_SUBST([FILE_HAS_ACL_LIB])
])
+
+# Prerequisites of module qcopy-acl.
+AC_DEFUN([gl_QCOPY_ACL],
+[
+ AC_REQUIRE([gl_FUNC_ACL])
+ AC_CHECK_HEADERS_ONCE([linux/xattr.h])
+ gl_FUNC_XATTR
+ if test "$use_xattr" = yes; then
+ QCOPY_ACL_LIB="$LIB_XATTR"
+ else
+ QCOPY_ACL_LIB="$LIB_ACL"
+ fi
+ AC_SUBST([QCOPY_ACL_LIB])
+])
Files:
lib/qcopy-acl.c
+m4/acl.m4
m4/xattr.m4
Depends-on:
acl-permissions [test "$use_xattr" != yes]
configure.ac:
-gl_FUNC_XATTR
-AC_REQUIRE([gl_FUNC_ACL])
-if test "$use_xattr" = yes; then
- QCOPY_ACL_LIB="$LIB_XATTR"
-else
- QCOPY_ACL_LIB="$LIB_ACL"
-fi
-AC_SUBST([QCOPY_ACL_LIB])
+gl_QCOPY_ACL
Makefile.am:
lib_SOURCES += qcopy-acl.c