sudo'ing with rsync probably stomps on --rysnc-path setting
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 737
- Forks
- 214
- PR merge metrics
- No merged PRs in 30d
Description
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'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/Rex/Commands/Rsync.pm around line 163 and trace how Rex::is_sudo modifies the rsync parameters. Reproduce the issue with the provided sync() call and inspect the generated command. Done means a supplied --rsync-path is preserved and sudo is incorporated so the remote command contains --rsync-path only once.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100