mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 11:58:43 +00:00
(cherry picked from commitf7e976f3da) (cherry picked from commitdb20b1876d) Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
1b9461325c
commit
3a7030426e
3
changelogs/fragments/1158-select-fix.yml
Normal file
3
changelogs/fragments/1158-select-fix.yml
Normal file
@ -0,0 +1,3 @@
|
||||
bugfixes:
|
||||
- "docker, nsenter connection plugins - fix handling of ``become`` plugin password prompt handling in case multiple events arrive at the same time
|
||||
(https://github.com/ansible-collections/community.docker/pull/1158)."
|
||||
@ -388,16 +388,21 @@ class Connection(ConnectionBase):
|
||||
stdout, stderr = p.communicate()
|
||||
raise AnsibleError('timeout waiting for privilege escalation password prompt:\n' + to_native(become_output))
|
||||
|
||||
chunks = b""
|
||||
for key, event in events:
|
||||
if key.fileobj == p.stdout:
|
||||
chunk = p.stdout.read()
|
||||
if chunk:
|
||||
chunks += chunk
|
||||
elif key.fileobj == p.stderr:
|
||||
chunk = p.stderr.read()
|
||||
if chunk:
|
||||
chunks += chunk
|
||||
|
||||
if not chunk:
|
||||
if not chunks:
|
||||
stdout, stderr = p.communicate()
|
||||
raise AnsibleError('privilege output closed while waiting for password prompt:\n' + to_native(become_output))
|
||||
become_output += chunk
|
||||
become_output += chunks
|
||||
finally:
|
||||
selector.close()
|
||||
|
||||
|
||||
@ -170,16 +170,21 @@ class Connection(ConnectionBase):
|
||||
stdout, stderr = p.communicate()
|
||||
raise AnsibleError('timeout waiting for privilege escalation password prompt:\n' + to_native(become_output))
|
||||
|
||||
chunks = b""
|
||||
for key, event in events:
|
||||
if key.fileobj == p.stdout:
|
||||
chunk = p.stdout.read()
|
||||
if chunk:
|
||||
chunks += chunk
|
||||
elif key.fileobj == p.stderr:
|
||||
chunk = p.stderr.read()
|
||||
if chunk:
|
||||
chunks += chunk
|
||||
|
||||
if not chunk:
|
||||
if not chunks:
|
||||
stdout, stderr = p.communicate()
|
||||
raise AnsibleError('privilege output closed while waiting for password prompt:\n' + to_native(become_output))
|
||||
become_output += chunk
|
||||
become_output += chunks
|
||||
finally:
|
||||
selector.close()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user