mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix encoding error with path to ssh
As reported on the mailing list, if ssh_executable (from a config setting) contains nonascii characters then we could get a UnicodeError here. Transform into bytes before passing to subprocess so that subprocess doesn't transform to bytes for us.
This commit is contained in:
parent
e93ecac0da
commit
86d8a4ff50
1 changed files with 4 additions and 1 deletions
|
@ -22,6 +22,8 @@ __metaclass__ = type
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_bytes
|
||||||
|
|
||||||
|
|
||||||
_HAS_CONTROLPERSIST = {}
|
_HAS_CONTROLPERSIST = {}
|
||||||
|
|
||||||
|
@ -33,9 +35,10 @@ def check_for_controlpersist(ssh_executable):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
b_ssh_exec = to_bytes(ssh_executable, errors='surrogate_or_strict')
|
||||||
has_cp = True
|
has_cp = True
|
||||||
try:
|
try:
|
||||||
cmd = subprocess.Popen([ssh_executable, '-o', 'ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
cmd = subprocess.Popen([b_ssh_exec, '-o', 'ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
(out, err) = cmd.communicate()
|
(out, err) = cmd.communicate()
|
||||||
if b"Bad configuration option" in err or b"Usage:" in err:
|
if b"Bad configuration option" in err or b"Usage:" in err:
|
||||||
has_cp = False
|
has_cp = False
|
||||||
|
|
Loading…
Reference in a new issue