Skip to content

Commit

Permalink
Fix missing quoting for remote_tmp in second mkdir of shell module. I…
Browse files Browse the repository at this point in the history
…ssue ansible#69577 (ansible#69578) (ansible#70758)

* Fix missing quoting for remote_tmp in second mkdir of shell module. Issue ansible#69577

* adding changelog

* fixing typo in changelog entry

* adding test case

Adding test case written by bmillemayhias.

* using $HOME instead of ~

* fixing commit measage

* Update 69578-shell-remote_tmp-quoting.yaml

Co-authored-by: Brian Kohles <me@briankohles.com>
(cherry picked from commit 77d0eff)

Co-authored-by: Brian Kohles <briankohles@users.noreply.github.com>
  • Loading branch information
bmillemathias and briankohles committed Aug 6, 2020
1 parent 76f591e commit 84afa8e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/69578-shell-remote_tmp-quoting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- shell - fix quoting of mkdir command in creation of remote_tmp in order to allow spaces and other special characters (https://github.com/ansible/ansible/issues/69577).
2 changes: 1 addition & 1 deletion lib/ansible/plugins/shell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def mkdtemp(self, basefile=None, system=False, mode=0o700, tmpdir=None):

# use mkdir -p to ensure parents exist, but mkdir fullpath to ensure last one is created by us
cmd = 'mkdir -p %s echo %s %s' % (self._SHELL_SUB_LEFT, basetmpdir, self._SHELL_SUB_RIGHT)
cmd += '%s mkdir %s' % (self._SHELL_AND, basetmp)
cmd += '%s mkdir %s echo %s %s' % (self._SHELL_AND, self._SHELL_SUB_LEFT, basetmp, self._SHELL_SUB_RIGHT)
cmd += ' %s echo %s=%s echo %s %s' % (self._SHELL_AND, basefile, self._SHELL_SUB_LEFT, basetmp, self._SHELL_SUB_RIGHT)

# change the umask in a subshell to achieve the desired mode
Expand Down
5 changes: 5 additions & 0 deletions test/integration/targets/config/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ ANSIBLE_TIMEOUT= ansible -m ping testhost -i ../../inventory "$@"

# env var is wrong type, this should be a fatal error pointing at the setting
ANSIBLE_TIMEOUT='lola' ansible -m ping testhost -i ../../inventory "$@" 2>&1|grep 'Invalid type for configuration option setting: DEFAULT_TIMEOUT'

# https://github.com/ansible/ansible/issues/69577
ANSIBLE_REMOTE_TMP="$HOME/.ansible/directory_with_no_space" ansible -m ping testhost -i ../../inventory "$@"

ANSIBLE_REMOTE_TMP="$HOME/.ansible/directory with space" ansible -m ping testhost -i ../../inventory "$@"

0 comments on commit 84afa8e

Please sign in to comment.