summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-01-22 12:31:32 -0800
committerJames Cammarata <jimi@sngx.net>2015-02-17 13:59:08 -0600
commitf32e9f0e54c7ef532c8e94350b3f4d24f795e270 (patch)
tree38cbb3a968a80b6600673bd5d1beac8dad619fe7
parentec2a9cbd11ef1878595ff169cfc8235dea2ba0fb (diff)
downloadansible-f32e9f0e54c7ef532c8e94350b3f4d24f795e270.tar.gz
Fix quoting of shell parameters used in remote_checksum and add integration test to detect the error
Fixes #682 Conflicts: test/integration/roles/test_unarchive/tasks/main.yml v2/ansible/plugins/shell/sh.py
-rw-r--r--lib/ansible/runner/shell_plugins/sh.py5
-rw-r--r--test/integration/roles/test_unarchive/tasks/main.yml1
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/ansible/runner/shell_plugins/sh.py b/lib/ansible/runner/shell_plugins/sh.py
index 95d48e9e7d..c43a8e725c 100644
--- a/lib/ansible/runner/shell_plugins/sh.py
+++ b/lib/ansible/runner/shell_plugins/sh.py
@@ -79,7 +79,6 @@ class ShellModule(object):
return 'echo %s' % user_home_path
def checksum(self, path, python_interp):
- path = pipes.quote(path)
# The following test needs to be SH-compliant. BASH-isms will
# not work if /bin/sh points to a non-BASH shell.
#
@@ -97,14 +96,14 @@ class ShellModule(object):
# 0. This logic is added to the end of the cmd at the bottom of this
# function.
- test = "rc=flag; [ -r \"%(p)s\" ] || rc=2; [ -f \"%(p)s\" ] || rc=1; [ -d \"%(p)s\" ] && rc=3; %(i)s -V 2>/dev/null || rc=4; [ x\"$rc\" != \"xflag\" ] && echo \"${rc} %(p)s\" && exit 0" % dict(p=path, i=python_interp)
+ test = "rc=flag; [ -r \'%(p)s\' ] || rc=2; [ -f \'%(p)s\' ] || rc=1; [ -d \'%(p)s\' ] && rc=3; %(i)s -V 2>/dev/null || rc=4; [ x\"$rc\" != \"xflag\" ] && echo \"${rc}\"\' %(p)s\' && exit 0" % dict(p=path, i=python_interp)
csums = [
"(%s -c 'import hashlib; print(hashlib.sha1(open(\"%s\", \"rb\").read()).hexdigest())' 2>/dev/null)" % (python_interp, path), # Python > 2.4 (including python3)
"(%s -c 'import sha; print(sha.sha(open(\"%s\", \"rb\").read()).hexdigest())' 2>/dev/null)" % (python_interp, path), # Python == 2.4
]
cmd = " || ".join(csums)
- cmd = "%s; %s || (echo \"0 %s\")" % (test, cmd, path)
+ cmd = "%s; %s || (echo \'0 %s\')" % (test, cmd, path)
return cmd
def build_module_command(self, env_string, shebang, cmd, rm_tmp=None):
diff --git a/test/integration/roles/test_unarchive/tasks/main.yml b/test/integration/roles/test_unarchive/tasks/main.yml
index 7caa68e65c..b33a836790 100644
--- a/test/integration/roles/test_unarchive/tasks/main.yml
+++ b/test/integration/roles/test_unarchive/tasks/main.yml
@@ -136,3 +136,4 @@
- name: remove our unarchive destination
file: path=/tmp/foo-unarchive.txt state=absent
+