diff options
author | Brian Kohles <briankohles@users.noreply.github.com> | 2020-07-20 09:25:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 11:25:29 -0500 |
commit | 77d0effcc5b2da1ef23e4ba32986a9759c27c10d (patch) | |
tree | 70bc655aca945550c62d37fb63a91be3cb2a234d | |
parent | 84b4387702b50a47a95cab1e289af506161b3f1b (diff) | |
download | ansible-77d0effcc5b2da1ef23e4ba32986a9759c27c10d.tar.gz |
Fix missing quoting for remote_tmp in second mkdir of shell module. Issue #69577 (#69578)
* Fix missing quoting for remote_tmp in second mkdir of shell module. Issue #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>
-rw-r--r-- | changelogs/fragments/69578-shell-remote_tmp-quoting.yaml | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/shell/__init__.py | 2 | ||||
-rwxr-xr-x | test/integration/targets/config/runme.sh | 5 |
3 files changed, 8 insertions, 1 deletions
diff --git a/changelogs/fragments/69578-shell-remote_tmp-quoting.yaml b/changelogs/fragments/69578-shell-remote_tmp-quoting.yaml new file mode 100644 index 0000000000..b545dc6426 --- /dev/null +++ b/changelogs/fragments/69578-shell-remote_tmp-quoting.yaml @@ -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). diff --git a/lib/ansible/plugins/shell/__init__.py b/lib/ansible/plugins/shell/__init__.py index 3db3bcc532..8aeab292ab 100644 --- a/lib/ansible/plugins/shell/__init__.py +++ b/lib/ansible/plugins/shell/__init__.py @@ -164,7 +164,7 @@ class ShellBase(AnsiblePlugin): # 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 diff --git a/test/integration/targets/config/runme.sh b/test/integration/targets/config/runme.sh index 068eed0c9a..c7fe01420c 100755 --- a/test/integration/targets/config/runme.sh +++ b/test/integration/targets/config/runme.sh @@ -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 "$@"
\ No newline at end of file |