I've been thus far unable to figure out why this breaks.
There seem to be three distinct problems.
Problem #1: receiver.c:451 calls set_file_attrs before the contents
of a directory have been created. This resets the writable flag which
was setup in generator.c to permit creating children. This causes
files that are children of a read-only directory with extended
attributes to fail.
Problem #2: generator.c creates directories with mode file->mode. If
the directory has no contents, the flags are never made writable.
This causes the call in receiver.c to fail to create the extended
attributes.
Problem #3: generator.c also calls set_file_attrs early (before
xattrs are available) which will reset the permissions on directories
even if #2 is fixed. This is also the point at which the %stat xattr
gets set.
I think the solution to #2 is to add 0700 to non-root created
directories and tweak the directory mode always. This will make
setting the %stat attr in the early set_file_attrs succeed.
#3 must then be taught to leave this mode tweak alone.
#1 should perhaps only call the set_xattr code, not the whole
set_file_attrs. After all, the earlier set_file_attrs already dealt
with permissions.
There also seems to be some race-condition between the generator and
receiver. I noticed that if I placed sleep commands in the generator
other things start to fail. I didn't investigate this further.
I can't fix these problems on my own because I barely understand the
correct order of the operations.
Here is the test case that I'm using:
mkdir y
cd y
touch file1
mkdir no-xattr
mkdir no-xattr-stuff
mkdir xattr
mkdir xattr-stuff
touch no-xattr-stuff/file2
touch xattr-stuff/file3
setfattr -n user.test1 -v foo .
setfattr -n user.test2 -v bar xattr
setfattr -n user.test3 -v baz xattr-stuff
chmod -w * .
cd ..
rsync -aX y z
If you can get this to work. Hats off to you!
--
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html