btrfs-progs: receive: restore capabilities after chown
authorDavid Sterba <dsterba@suse.cz>
Wed, 27 May 2015 16:29:57 +0000 (18:29 +0200)
committerDavid Sterba <dsterba@suse.cz>
Wed, 27 May 2015 16:49:59 +0000 (18:49 +0200)
commit123a2a085027eee7212a0c13921f574d65847c9f
treed403766e62b7a7b2b8e0a03f78fd6b9c05407d4f
parentab747f84cad2047dcc7eb2850f4c9251437eb50b
btrfs-progs: receive: restore capabilities after chown

Capabilities are cleared after chown, and the btrfs-stream encodes the
CHOWN command after any SET_XATTR command. So the capabilites are not
always preserved.

This could be fixed in kernel to emit the instructions in the right
order, but fix in userspace will make it work for older kernels.

If we see the capabilities among xattrs, cache the value and apply it
again in case it's followed by chown on that file.

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=68891
Reported-by: Juan Orti Alcaine <j.orti.alcaine@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-receive.c