1
0
Fork 0
mirror of https://github.com/ansible-collections/ansible.posix.git synced 2026-02-04 08:01:49 +00:00

Synchronize: properly quote shell command components

The synchronize action plugin and module were a bit sloppy when it
came to the command-line parameter quoting and that caused failuer on
some systems (for example, on Fedora 34).

This commit makes sure any argumnts with potentially problematic
characters are quoted before being used.
This commit is contained in:
Tadej Borovšak 2021-08-04 12:02:44 +02:00
parent 5282ece77e
commit db12a40a4c
3 changed files with 11 additions and 7 deletions

View file

@ -548,10 +548,10 @@ def main():
ssh_cmd_str = ' '.join(shlex_quote(arg) for arg in ssh_cmd)
if ssh_args:
ssh_cmd_str += ' %s' % ssh_args
cmd.append(shlex_quote('--rsh=%s' % ssh_cmd_str))
cmd.append('--rsh=%s' % shlex_quote(ssh_cmd_str))
if rsync_path:
cmd.append(shlex_quote('--rsync-path=%s' % rsync_path))
cmd.append('--rsync-path=%s' % shlex_quote(rsync_path))
if rsync_opts:
if '' in rsync_opts:
@ -577,7 +577,7 @@ def main():
cmd.append('--link-dest=%s' % link_path)
changed_marker = '<<CHANGED>>'
cmd.append(shlex_quote('--out-format=' + changed_marker + '%i %n%L'))
cmd.append('--out-format=%s' % shlex_quote(changed_marker + '%i %n%L'))
# expand the paths
if '@' not in source: