Search code examples
parameterscygwinargumentsrsync

How can I get all rsync parameters called in a single rsync against a host?


I'm attempting to parse the parameters passed when rsync is run against a host. So if I passed --delete --prune-empty-dirs and --timeout=60, I would want to know that. I know I can use pre-xfer exec in my rsyncd.conf file, and it will allow me to pass the arguments to another script (ex: $RSYNC_ARG0,$RSYNC_ARG1,...$RSYNC_ARGN). The problem I'm having is that some of these come back as actual arguments:

bwlimit=100000

delete

But others come back as weird strings:

vOtre.iLsf

Is there any way to parse these strings to determine what arguments/parameters were passed? These are the arguments I passed to the syncing host:

--recursive --times --omit-dir-times --timeout=15 --bwlimit=100000 --port=38700 --quiet --exclude='string1' --exclude='string2' --exclude='string3' --exclude='string4' --exclude='string5' --exclude='string6' --exclude='string7' --timeout=60 --delete --prune-empty-dirs

and these are the arguments I got in pre-xfer exec (comma separated):

server,mOtre.isf,timeout=60,bwlimit=100000,delete

Any help would be greatly appreciated.

I don't know if this matters, but I'm syncing from a Linux box to rsync in cygwin on a Windows box. I would assume the parameters/arguments/values are the same, but I figured it was worth noting.

EDIT mOtr stands for --prune-empty-dirs --omit-dir-times --times --recursive, but I don't know what anything after the . means...


Solution

  • On the server side, you're not directly seeing the options that are given to the client side command. The client side command parses your options, and then generates a set of options to pass to the server rsync process.

    The server only gets the the options that it needs to know about to do it's part. For example, the exclude option is part of the file selection process which is carried out via the rsync protocol on the network connection between the two sides. It does not get passed to the server side via command line.

    The blob of random characters is a string built on the client that has a coded set of flags that the server needs to know about. Some of these have the same meaning as the short options on the rsync command line (as you guessed), but others have different meanings or are unique to the server's operation. (you can find out if you look at the function 'server_options' in options.c if you download the source code)

    Unfortunately, if you want to make decisions based on the exact command line passed to the client side command, you are probably out of luck. However there may be enough info there with the other environment variables and what is passed in RSYNC_ARG to still do what you need to.

    If your goal is to block certain activities by having the pre-xfer script fail, you may also be able to do some of that by setting other limits and restrictions in rsyncd.conf

    good luck!