Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btrfs: send: Re emit file capabilities when chown is emitted
[PROBLEM] Whenever a chown is executed, all capabilities of the file being touched are lost. When doing incremental send with a file with capabilities, there is a situation where the capability can be lost in the receiving side. The sequence of actions bellow shows the problem: $ mount /dev/sda fs1 $ mount /dev/sdb fs2 $ touch fs1/foo.bar $ setcap cap_sys_nice+ep fs1/foo.bar $ btrfs subvol snap -r fs1 fs1/snap_init $ btrfs send fs1/snap_init | btrfs receive fs2 $ chgrp adm fs1/foo.bar $ setcap cap_sys_nice+ep fs1/foo.bar $ btrfs subvol snap -r fs1 fs1/snap_complete $ btrfs subvol snap -r fs1 fs1/snap_incremental $ btrfs send fs1/snap_complete | btrfs receive fs2 $ btrfs send -p fs1/snap_init fs1/snap_incremental | btrfs receive fs2 At this point, a chown was emitted by "btrfs send" since only the group was changed. This makes the cap_sys_nice capability to be dropped from fs2/snap_incremental/foo.bar [FIX] Emit all capabilities when a chown is being emitted. The current code first checks for xattrs that are new/changed, emits them, and later emit the chown. To avoid sending the xattrs duplicated, a new flag is introduced in send_context. Link: kdave/btrfs-progs#202 Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
- Loading branch information