On 28/11/2026 15:51, Andreas Gruenbacher wrote:
static int
is_attr_permissions (const char *name, struct error_context *ctx)
{
+ struct copy_context *copy_ctx =
+ (struct copy_context *) (void *)
+ ((char *)ctx - offsetof (struct copy_context, ctx));
+
/* 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 streq (name, XATTR_NAME_POSIX_ACL_ACCESS)
- || streq (name, XATTR_NAME_POSIX_ACL_DEFAULT)
- || streq (name, XATTR_NAME_NFSV4_ACL)
+ if (streq (name, XATTR_NAME_POSIX_ACL_ACCESS))
+ {
+ copy_ctx->posix_acl_access = true;
+ return true;
+ }
+ if (streq (name, XATTR_NAME_POSIX_ACL_DEFAULT))
+ {
+ copy_ctx->posix_acl_default = true;
+ return true;
+ }
+ return streq (name, XATTR_NAME_NFSV4_ACL)
|| attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS;
}
Shouldn't we set both copy_ctx->posix_acl_{access,default} = true;
in the XATTR_NAME_NFSV4_ACL case also.
Do we really want to try and set a POSIX ACL in this case?
I think that may give ENOTSUP errors for non trivial ACLs?
@@ -89,10 +116,28 @@ qcopy_acl (const char *src_name, int source_desc, const
char *dst_name,
to copy */
if (ret == 0)
{
+ struct copy_context copied = {};
+
ret = source_desc < 0 || dest_desc < 0
- ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL)
+ ? attr_copy_file (src_name, dst_name, is_attr_permissions, &copied.ctx)
: attr_copy_fd (src_name, source_desc, dst_name, dest_desc,
- is_attr_permissions, NULL);
+ is_attr_permissions, &copied.ctx);
+
#if USE_ACL ?
+ if (ret == 0 && !copied.posix_acl_access)
+ {
+ acl_t acl = acl_from_mode (mode);
+ ret = dest_desc < 0
+ ? acl_set_file (dst_name, ACL_TYPE_ACCESS, acl)
+ : acl_set_fd (dest_desc, acl);
+ acl_free (acl);
+ }
+
+ if (ret == 0 && S_ISDIR (mode) && !copied.posix_acl_default)
+ {
+ ret = dest_desc < 0 || ! HAVE_ACL_DELETE_DEF_FILE_AT
+ ? acl_delete_def_file (dst_name)
+ : acl_delete_def_file_at (dest_desc, "", AT_EMPTY_PATH);
+ }
#endif
cheers,
Padraig