Bug 10705 - usermap/groupmap do not escape wildcards passed to the remote
Summary: usermap/groupmap do not escape wildcards passed to the remote
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.1.1
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-09 05:59 UTC by Daniel O'Connor
Modified: 2020-07-26 08:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel O'Connor 2014-07-09 05:59:48 UTC
Hi,
I was trying to map all GID/UID to 0:0 with..
rsync --chown 0:0 foo user@remote:/tmp

but it bombs out with..
rsync: No match.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]

I am guessing that --chown 0:0 maps internally to --usermap *:0 --groupmap *:0 but they aren't escaped properly.

As a work around I am using..
rsync --usermap \\\*:0 --groupmap \\\*:0 foo user@remote:/tmp

and it works.
(i.e. the *'s are escaped enough the remote invocation doesn't fail).

I imagine this would also work if the remote shell did not error on non-matching globs, however I think the existing behaviour is still broken as if the glob did match the behaviour could be very odd.
Comment 1 Daniel O'Connor 2014-07-10 01:21:17 UTC
I looked through the code and found the --protect-args option which does make --chown work.

I guess it would be difficult to fix unless the wildcard character was changed to something else.

Perhaps the best work around for now would be to mention --protect-args in the --chown/--usermap/--groupmap options in the man page?
Comment 2 Wayne Davison 2020-07-26 08:09:17 UTC
I added a comment about --protect-args to the man page.

Most people don't run into this issue because the wild cards are connected to the mapping option using an equal sign, and most shells pass through unmatched wildcards with nary a wimper (e.g. bash).  I use zsh, but I only set the option to complain about an empty glob for an interactive shell, so it doesn't affect me either. These days I also like to compile my rsync with --protect-args enabled by default (which I nearly included in 3.2.0, but I was a bit worried about backward compatibility issues).