Rex icon indicating copy to clipboard operation
Rex copied to clipboard

sudo'ing with rsync probably stomps on --rysnc-path setting

Open sdondley opened this issue 5 years ago • 0 comments

Describe the bug

If I want to rsync with a nice setting of 19, I would do:

rsync --rsync-path='nice -n 19 rsync' <src> <destination>

If I want to run this with sudo, I would do:

rsync --rsync-path='sudo nice -n 19 rsync' <src> <destination>

The way the module is currently written, if Rex::is_sudo is true, then --rsync-path gets set to sudo rsync. See https://github.com/RexOps/Rex/blob/master/lib/Rex/Commands/Rsync.pm#L163

This would possibly stomp on any --rsync-path setting I set in the options to the Rex sync() command like in the first example above: nice -n 19 rsync.

How to reproduce it

Run this in a Rex task:

sudo TRUE;
sync($source, $dest, { parameters => '--rsync-path="nice -n 19 rsync"' })

Expected behavior

Something like following command should be run on the remote machine, with --rsync-path only appearing once and sudo coming before the nice command and option:

rsync $source $dest --rsync-path='sudo nice -n 19 rsync'

Actual behavior

Instead, the following command gets run with --rsync-path appearing twice:

rsync $source $dest --rsync-path='nice -n 19 rsync' --rsync-path='sudo rsync'

sdondley avatar Jun 25 '20 20:06 sdondley