Permissions of the top-level destination directory without --perms

Matt McCutchen hashproduct+rsync at gmail.com
Fri Feb 16 23:05:16 GMT 2007


I noticed that rsync sometimes miscalculates the permissions of the
top-level destination directory when --perms is off.  For example, run
these commands in an area free of default ACLs:

umask 0000
mkdir -p src/foo
chmod 700 src src/foo
rsync -r src/ dest/
find . -ls

763054    0 drwx------   4 matt     matt           96 Feb 16 17:57 .
763158    0 drwx------   3 matt     matt           72 Feb 16 17:57 ./src
1424849    0 drwx------   2 matt     matt           48 Feb 16 17:57 ./src/foo
1075094    0 drwxrwxrwx   3 matt     matt           72 Feb 16 17:57 ./dest
1511362    0 drwx------   2 matt     matt           48 Feb 16 17:57 ./dest/foo

Notice that the permissions of dest/foo were correctly restricted by
the 700 permissions of src/foo, but the permissions of dest were not
restricted by the permissions of src.

The trouble is that the generator creates the top-level destination
directory in get_local_name with default permissions and then treats
it as already existing, so it doesn't change the permissions.  The
generator then checks new_root_dir and begins pretending the directory
doesn't exist so that it can itemize the creation correctly.  Moving
the pretending above the permission calculation (as in the attached
patch) seems to fix the problem.

Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: root-dir-perms.diff
Type: text/x-patch
Size: 958 bytes
Desc: not available
Url : http://lists.samba.org/archive/rsync/attachments/20070216/b8d18db2/root-dir-perms.bin


More information about the rsync mailing list