Fix problems with non-ascii values passed as part of the command to connection plugins

@drybjed discovered this with non-ascii environment variables and
command line arguments to script and raw module.
This commit is contained in:
Toshio Kuratomi 2016-01-04 19:23:12 -08:00
parent 8d57ffd16b
commit c0a8cd950b
10 changed files with 97 additions and 13 deletions

View file

@ -30,6 +30,7 @@ from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.plugins.connection import ConnectionBase
from ansible.module_utils.basic import is_executable
from ansible.utils.unicode import to_bytes
try:
from __main__ import display
@ -90,6 +91,7 @@ class Connection(ConnectionBase):
local_cmd = [self.chroot_cmd, self.chroot, executable, '-c', cmd]
display.vvv("EXEC %s" % (local_cmd), host=self.chroot)
local_cmd = map(to_bytes, local_cmd)
p = subprocess.Popen(local_cmd, shell=False, stdin=stdin,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)