Bug 4757 - Daemon mis-logs paths if module path in rsyncd.conf is relative
Summary: Daemon mis-logs paths if module path in rsyncd.conf is relative
Status: CLOSED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.0
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-01 20:14 UTC by Matt McCutchen
Modified: 2008-07-26 10:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt McCutchen 2007-07-01 20:14:36 UTC
I set up an rsync daemon in /home/matt/test/daemon-log-paths/daemon with this rsyncd.conf:

log file = rsyncd.log
transfer logging = yes
log format = %i %f
pid file = rsyncd.pid
port = 3142
use chroot = no

[module]
        path = dir/
        read only = false
        auth users = user
        secrets file = module.secrets

Then I pushed a directory to it as follows:

[matt@mattlaptop2 daemon-log-paths]$ pwd
/home/matt/test/daemon-log-paths
[matt@mattlaptop2 daemon-log-paths]$ ls -l src
total 0
-rw------- 1 matt matt 0 2007-07-01 18:06 a
[matt@mattlaptop2 daemon-log-paths]$ ls -l daemon/dir/subdir
total 0
-rw------- 1 matt matt 0 2007-07-01 18:06 b
[matt@mattlaptop2 daemon-log-paths]$ ~/rsync/rsync/rsync -rt --del src/ rsync://user@localhost:3142/module/subdir/
Password: 
[matt@mattlaptop2 daemon-log-paths]$ 

The resulting rsyncd.log was:

2007/07/01 21:04:23 [8458] rsyncd version 3.0.0cvs starting, listening on port 3142
2007/07/01 21:05:17 [8499] connect from localhost (127.0.0.1)
2007/07/01 21:05:18 [8499] rsync to module/subdir/ from user@localhost (127.0.0.1)
2007/07/01 21:05:18 [8499] receiving file list
2007/07/01 21:05:18 [8499] *deleting me/matt/test/daemon-log-paths/daemon/dir/subdir/b
2007/07/01 21:05:18 [8499] .d..t...... me/matt/test/daemon-log-paths/daemon/dir/subdir/.
2007/07/01 21:05:18 [8499] >f+++++++++ me/matt/test/daemon-log-paths/daemon/dir/subdir/a
2007/07/01 21:05:18 [8499] sent 96 bytes  received 183 bytes  total size 0

I expected the logged paths to be relative to the root of the module as per Wayne's remarks at http://lists.samba.org/archive/rsync/2007-June/017896.html , but instead they are absolute paths missing the first few characters.

The trouble is that rsync sets module_dirlen to the length of the module path as given in rsyncd.conf at line 371 of clientserver.c but then uses it as an index into curr_dir at line 535 of log.c .  curr_dir begins with the absolute, symlink-free path of the module, but if the path in rsyncd.conf is relative or uses symlinks, skipping its length in curr_dir is meaningless.  To fix the bug, rsync needs to set module_dirlen to the length of its current directory right after it chdirs into the module.
Comment 1 Wayne Davison 2007-07-01 21:02:24 UTC
It is not valid for the path to be relative.
Comment 2 Matt McCutchen 2007-07-02 07:14:04 UTC
Bummer.  Please document that in the rsyncd.conf man page.
Comment 3 Wayne Davison 2007-07-14 17:35:54 UTC
I decided to add code to figure out the absolute path of a relative-path module.  Should be fixed now.