Can't script failure for missing --password-file
rsync-list at dimebar.com
Tue Aug 2 14:40:22 MDT 2011
I've a script which calls:
rsync --password-file=password.txt rsync://server/files /files
However, due to an unrelated error password.txt was missing.
In authenticate.c:auth_client, the code tries to read from the password file,
then tries the RSYNC_PASSWORD env var, then calls getpass(3). This last step is
causing problems as, even though the script is intended to run unattended, it
stops at the password prompt.
This only happens when running with a controlling tty (more specifically,
without a controlling tty getpass(3) can't open /dev/tty), for example, in the
%post script of a Redhat / Fedora kickstart file.
# rsync -vv --password-file=password.txt rsync://server/files /files < /dev/null
opening tcp connection to server port 873
opening connection using --server --sender -vv . files
rsync: could not open password file "password.txt": No such file or directory (2)
<< rsync waits forever here >>
Suggested fix is to error-out in auth_client() when the given requested
--password-file can't be used, rather than trying to continue with other
Wrapping up rsync in a setsid caller avoids the problem, but dissociates from
the shell so it's impossible to catch exit status.
Quoting the manpage, "You can avoid the password prompt by ... using the
--password-file option." This is not true in all cases.
Apologies if this issue has already been discussed; I found nothing from
searching in bugzilla or the list archives.
More information about the rsync