Ensure that the become password is written on py3 in the ssh connection plugin. Fixes #34727
(cherry picked from commit 29c1d5cb5d
)
This commit is contained in:
parent
95e162dc32
commit
bd4b92c0b6
2 changed files with 4 additions and 0 deletions
|
@ -758,6 +758,9 @@ class Connection(ConnectionBase):
|
||||||
if self._flags['become_prompt']:
|
if self._flags['become_prompt']:
|
||||||
display.debug('Sending become_pass in response to prompt')
|
display.debug('Sending become_pass in response to prompt')
|
||||||
stdin.write(to_bytes(self._play_context.become_pass) + b'\n')
|
stdin.write(to_bytes(self._play_context.become_pass) + b'\n')
|
||||||
|
# On python3 stdin is a BufferedWriter, and we don't have a guarantee
|
||||||
|
# that the write will happen without a flush
|
||||||
|
stdin.flush()
|
||||||
self._flags['become_prompt'] = False
|
self._flags['become_prompt'] = False
|
||||||
state += 1
|
state += 1
|
||||||
elif self._flags['become_success']:
|
elif self._flags['become_success']:
|
||||||
|
|
|
@ -457,6 +457,7 @@ class TestSSHConnectionRun(object):
|
||||||
self.mock_selector.get_map.side_effect = lambda: True
|
self.mock_selector.get_map.side_effect = lambda: True
|
||||||
|
|
||||||
return_code, b_stdout, b_stderr = self.conn._run("ssh", "this is input data")
|
return_code, b_stdout, b_stderr = self.conn._run("ssh", "this is input data")
|
||||||
|
self.mock_popen_res.stdin.flush.assert_called_once_with()
|
||||||
assert return_code == 0
|
assert return_code == 0
|
||||||
assert b_stdout == b'abc'
|
assert b_stdout == b'abc'
|
||||||
assert b_stderr == b'123'
|
assert b_stderr == b'123'
|
||||||
|
|
Loading…
Reference in a new issue