when running the rsync with -e/--rsh stunnel-rsync and an alternative port on the command line (--port 12345), when this port should be communicated to the "rsh" program to be evaluated, which could be simply done by setting the RSYNC_SSL_PORT environment variable in case the --port option was used with rsync.
I've committed code that sets an RSYNC_PORT value in the environment for any daemon-over-rsh connections. The value will be "0" if the default port is being assumed, or the specified port number. This lets a script choose their own default port while still being able to discern if the user manually requested port 873.
thanks but the default port handling does not work correctly yet. Calling rsync like: rsync --rsh=openssl-rsync -aiv HOST::module without any port definition, rsync sets the env var RSYNC_PORT=873 for the script. This is not what is desired here. Without an explicit port definition rsync should not be set to 873. Setting it to 0 as you mentioned in your commend would be fine.
Fixed.