Bug 6191 - rsyncd path does not support environmental variables
Summary: rsyncd path does not support environmental variables
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.9
Hardware: x86 Linux
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-16 16:09 UTC by Jerome
Modified: 2009-10-20 22:32 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 Jerome 2009-03-16 16:09:12 UTC
I need to have a module that saves the files to ~/backup, and the rsync complains that the path does not exist for ~/backup, $HOME/backup, and for /home/$USER/backup. The error is chdir failed, no such directory.
Comment 1 Matt McCutchen 2009-03-16 17:23:34 UTC
Indeed, environment variables are not recognized in the module path; that would be an enhancement.

This is being discussed on the list:
http://lists.samba.org/archive/rsync/2009-March/022903.html
Comment 2 Wayne Davison 2009-10-20 22:32:30 UTC
The git repository now supports the expansion of environment variables using %VAR% references.  I chose this idiom because I thought it would be less likely to have backward-compatibility issues, and it also stays with the DOS/Win style of the config file.

You can reference environment variables in the values of settings only, which does not include module names or parameter names.  All string values are evaluated late so that they can include the variables listed in the manpage section describing the pre-xfer exec scripts.  Values that are not strings (such as "use chroot = BOOL") are expanded at config-reading time so that the parameter can be set with the appropriate value type.

So, to get the authenticating user into a path as you requested (and indeed, even into a uid setting) you can do things like this:

[per-user-module]
    path = /home/%RSYNC_USER_NAME%
    uid = %RSYNC_USER_NAME%
    gid = *
    auth users = sally susan sam steve

One thing you can't do is this:

secrets file = /home/%RSYNC_USER_NAME%/.rsync-secret

That's because the needed environment variable isn't set until after the name and password has been validated.