summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2022-01-18 20:26:23 -0500
committerGitHub <noreply@github.com>2022-01-18 17:26:23 -0800
commit4eac144d7e7b8cdb5a167ae53e2e268ca2a94557 (patch)
treed770543d5576e9176d6e823874bc93ce6d2c771d /lib
parenta72e3d14b376ec89ad46eb9981151ae03c1d05c6 (diff)
downloadansible-4eac144d7e7b8cdb5a167ae53e2e268ca2a94557.tar.gz
ssh connection avoid parsing own debug (#76732) (#76756)
* ssh connection avoid parsiing own debug (#76732) - Avoids false positives on become strings being echoed back by ssh cli itself - added test for debug lines - also simplified some of existing test code (cherry picked from commit 0ff80a15ba40c2aff3b96c1152f19c97a92d3c97) * unicoode * dont make em ascii
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/plugins/connection/ssh.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index b563864d8e..d498683ecd 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -366,6 +366,7 @@ b_NOT_SSH_ERRORS = (b'Traceback (most recent call last):', # Python-2.6 when th
)
SSHPASS_AVAILABLE = None
+SSH_DEBUG = re.compile(r'^debug\d+: .*', flags=re.U)
class AnsibleControlPersistBrokenPipeError(AnsibleError):
@@ -800,7 +801,10 @@ class Connection(ConnectionBase):
suppress_output = False
# display.debug("Examining line (source=%s, state=%s): '%s'" % (source, state, display_line))
- if self.become.expect_prompt() and self.become.check_password_prompt(b_line):
+ if SSH_DEBUG.match(display_line):
+ # skip lines from ssh debug output to avoid false matches
+ pass
+ elif self.become.expect_prompt() and self.become.check_password_prompt(b_line):
display.debug(u"become_prompt: (source=%s, state=%s): '%s'" % (source, state, display_line))
self._flags['become_prompt'] = True
suppress_output = True