Matt McCutchen
2007-Feb-16 23:05 UTC
Permissions of the top-level destination directory without --perms
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
Paul Slootman
2007-Feb-17 14:42 UTC
Permissions of the top-level destination directory without --perms
On Fri 16 Feb 2007, Matt McCutchen wrote:> 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.Actually, I find the above behaviour to be what I'd expect; after all, you're telling it to transfer the contents of src, not src itself; and dest is an implied directory, and created with default permissions. Paul Slootman
Wayne Davison
2007-Feb-17 17:01 UTC
Permissions of the top-level destination directory without --perms
On Fri, Feb 16, 2007 at 06:05:16PM -0500, Matt McCutchen wrote:> Moving the pretending above the permission calculation (as in the > attached patch) seems to fix the problem.That change makes the later assignment of "real_ret = statret" wrong. I decided to check in a change that made the !preserve_perms check separate for the directory & non-directory code sections. ..wayne..