mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Fix password prompt matching (#24081)
* Fix password prompt matching * Add some tests for check_password_prompt * Prevent pep8 line ends with a space error
This commit is contained in:
parent
d8f76bed97
commit
040fb4435a
2 changed files with 83 additions and 4 deletions
|
@ -254,10 +254,8 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
|
|||
return False
|
||||
elif isinstance(self._play_context.prompt, string_types):
|
||||
b_prompt = to_bytes(self._play_context.prompt).strip()
|
||||
b_lines = b_output.splitlines(True)
|
||||
if not b_lines:
|
||||
return False
|
||||
return b_lines[-1].strip().endswith(b_prompt) or b_lines[0].strip().endswith(b_prompt)
|
||||
b_lines = b_output.splitlines()
|
||||
return any(l.strip().startswith(b_prompt) for l in b_lines)
|
||||
else:
|
||||
return self._play_context.prompt(b_output)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue