Bug 10163 - rsync -X is ineffective when setting owner/group
Summary: rsync -X is ineffective when setting owner/group
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
: 10295 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-09-23 10:23 UTC by Michal Luscon (mail bounces back)
Modified: 2013-12-23 17:50 UTC (History)
1 user (show)

See Also:


Attachments
Patch (1.07 KB, patch)
2013-09-23 10:23 UTC, Michal Luscon (mail bounces back)
no flags Details
Move xattr-setting after chowning. (2.24 KB, patch)
2013-11-28 21:28 UTC, Wayne Davison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Luscon (mail bounces back) 2013-09-23 10:23:41 UTC
Created attachment 9236 [details]
Patch

Description of problem:
rsync -X preserves extended attributes on files. It works partially; however, if combined with rsync options which preserve the file owner and/or group, it is partially ineffective. This is because rsync calls chown(2) after setting attributes, and chown removes security attributes (as in capabilities(5)).
Steps to Reproduce:

$ touch foo
$ sudo setcap cap_dac_read_search=pe foo
$ getcap foo
foo = cap_dac_read_search+ep
$ sudo rsync -X foo foo.1
$ getcap foo.1
foo.1 = cap_dac_read_search+ep
$ sudo rsync -aX foo foo.2
$ getcap foo.2
$

This report originates from https://bugzilla.redhat.com/show_bug.cgi?id=981797
Comment 1 Wayne Davison 2013-11-28 21:20:28 UTC
*** Bug 10295 has been marked as a duplicate of this bug. ***
Comment 2 Wayne Davison 2013-11-28 21:28:09 UTC
Created attachment 9492 [details]
Move xattr-setting after chowning.

Here's a patch I'm considering that also moves the mtime-setting code, along with the xattr-setting code (so that the modify time still gets set after setting xattrs).  Please do some testing and see if anything breaks.
Comment 3 Wayne Davison 2013-12-23 17:50:05 UTC
I've committed my proposed patch.