rsync: [receiver] rsync_xal_set: lsetxattr("/usr/bin/ping" (in some-host),"security.capability") failed: Operation not supported (95)
So not quite what I was thinking. The property security.capability is in the security namespace for xattrs, which I believe can be controlled by a security extension in the kernel (like selinux or apparmor). Even root can't write to that without permission of that security system. I think if you don't have one of those in your kernel at all then you can write anything you like to the security xattr namespace, but it's been a long time since I played with that, so I am not sure.
The normal way to set the capabilites that are stored in the security.capability xattr is with the capset or setcap command, and it displayed with the getcap command. These xattrs look like random text in getfattr. It might be nice to know that if you want to make a small test case.
I have 2 ideas you can try. First one is to make a small zvol (a block device inside of zfs) and create on it an ext4 filesystem to test on. The basic steps would be something like this
Code:
zfs create -V 20G tank/test_ext4
mkdir /mnt/test_ext4
mount /dev/zvol/tank/test_ext4 /mnt/test_ext4 -o user_xattr
cd /mnt/test_ext4
touch test_file
setcap 'cap_net_bind_service=+ep' test_file
And if that works, try to rsync just that ping file over.
I think that will fail because I think writing to that xattr is being denied by the extra security module in the kernel and not the filesystem, but it would be interesting to try it anyway, since if it works that might be your easiest option (except with an adequate size zvol, etc). To clean up after that, unmount that and then zfs destroy that zvol.
The other option is to use the --fake-super on rsync. You need to use this on the receiving side (so you might need to specify it as -M --fake-super if you are running rsync from the sending machine). This option tells rsync not to do things that need root, but instead fake it with some xattrs. So instead of changing the owner of a file, it will store the owner info in an xattr (in the user namespace). I believe that also means that your source file's security.capability xattr will be stored as user.rsync.security.capability (or something like that), so the writing should succeed.
Make sure you try a restore too. When restoring a backup, you will need the --fake-super on the sending rsync. That way the info in those special rsync xattrs will get translated back to their original values (so the restored file will get back the original owner).