Bug 2397782 - `cp --preserve=xattr a b` now fails when copying on a NFSv4
Summary: `cp --preserve=xattr a b` now fails when copying on a NFSv4
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: 42
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukáš Zaoral
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-09-24 11:19 UTC by Lukáš Zaoral
Modified: 2025-10-10 10:50 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:
lzaoral: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker FC-2494 0 None None None 2025-10-10 10:50:43 UTC

Description Lukáš Zaoral 2025-09-24 11:19:39 UTC
After some fix in kernel, `listxattr(3)` now lists `security.selinux` but this attribute cannot be set because it is apparently read-only and synthesised by the kernel:

# strace -s 100 --trace='/xattr' cp --preserve=xattr a b
flistxattr(3, NULL, 0)                  = 33
flistxattr(3, "system.nfs4_acl\0security.selinux\0", 33) = 33
fgetxattr(3, "system.nfs4_acl", NULL, 0) = 80
fgetxattr(3, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\207\0\0\0\6OWNER@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\6GROUP@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\tEVERYONE@\0\0", 80) = 80
fsetxattr(4, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\207\0\0\0\6OWNER@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\6GROUP@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\tEVERYONE@\0\0", 80, 0) = 0
fgetxattr(3, "security.selinux", NULL, 0) = 27
fgetxattr(3, "security.selinux", "system_u:object_r:nfs_t:s0", 27) = 27
fsetxattr(4, "security.selinux", "system_u:object_r:nfs_t:s0", 27, 0) = -1 EOPNOTSUPP (Operation not supported)
cp: setting attributes for 'b': Operation not supported

Well, the error itself is correct, `fsetxattr` failed, and `--preserve=mode` can be used as a workaround if the reason for using `--preserve=xattr` were NFSv4 ACLs,
but it still looks quite annoying.  The destination file will have `system_u:object_r:nfs_t:s0` synthesised anyway so despite the error it will end up with the same
xattrs as the source...

Originally reported in bz2397467#c5.


Note You need to log in before you can comment on or make changes to this bug.