Bug 4320 - Daemon should send stdout, stderr of {pre,post}-xfer command to client
Summary: Daemon should send stdout, stderr of {pre,post}-xfer command to client
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.0
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2007-01-02 16:48 UTC by Matt McCutchen
Modified: 2011-06-04 19:05 UTC (History)
0 users

See Also:

Patch to send pre-xfer output to client on error (3.63 KB, patch)
2007-09-22 23:24 UTC, Matt McCutchen
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt McCutchen 2007-01-02 16:48:35 UTC
It would be nice if an rsync daemon returned data that the pre-xfer or post-xfer command writes to stdout or stderr to the rsync client in the form of MSG_INFO and MSG_ERROR messages.

This enhancement would be good for two reasons:

- Pre-xfer and post-xfer commands could report progress and errors to the user.  In particular, a pre-xfer command could provide a meaningful error message to accompany rsync's "pre-xfer exec returned failure".

- An rsync daemon would be much more useful as a general-purpose daemon for remote command execution coupled with file transfer.  For example, I could script an automated programming contest judge around an rsync daemon.  A competitor would upload a submission to a module, and the post-xfer script would grade the submission and send back the results via stdout.
Comment 1 Matt McCutchen 2007-01-02 21:52:41 UTC
Sending the output of the post-xfer command would be harder than I originally thought because the daemon currently does not run the post-xfer command until after it has closed the connection to the client.  Furthermore, as soon as the receiving side has received all the files, it drops the connection.  So when a daemon sends files to an old client, the daemon has no way to make the client wait around for extra messages.  Of course, new clients could wait for extra messages followed by a special goodbye after pulling files from a daemon using protocol 30.
Comment 2 Matt McCutchen 2007-09-22 23:24:26 UTC
Created attachment 2927 [details]
Patch to send pre-xfer output to client on error

Here is a quick-and-dirty patch that makes the daemon return output from the pre-xfer command's stdout and stderr to the client *if* the pre-xfer command fails.  Unfortunately, rsync seems to escape newlines in the output.
Comment 3 Wayne Davison 2011-06-04 19:05:49 UTC
I prefer to leave stderr unaffected.  This provides a way for someone to debug their scripts using rsync --daemon --no-detach (and avoids unintended messages being sent to the user).

I have checked in a change that sends stdout to the user when the script returns an exit status (so, only on failure).  To return a message on success would require setting a global and outputting it later on in another file than clientserver.c (after the protocol gets fully setup), and is not something that I'm inclined to do at the moment.