ssh: fix issue #271 regression due to refactor, add test.

pull/607/head
David Wilson 6 years ago
parent 8d1b01d8ef
commit acade4ce88

@ -83,8 +83,11 @@ HOSTKEY_FAIL_PATTERN = re.compile(
)
# [user@host: ] permission denied
# issue #271: work around conflict with user shell reporting 'permission
# denied' e.g. during chdir($HOME) by only matching it at the start of the
# line.
PERMDENIED_PATTERN = re.compile(
b('(?:[^@]+@[^:]+: )?' # Absent in OpenSSH <7.5
b('^(?:[^@]+@[^:]+: )?' # Absent in OpenSSH <7.5
'Permission denied'),
re.I
)
@ -122,9 +125,6 @@ class SetupProtocol(mitogen.parent.RegexProtocol):
self.stream.conn._fail_connection(HostKeyError(hostkey_failed_msg))
def _on_permission_denied(self, line, match):
# issue #271: work around conflict with user shell reporting
# 'permission denied' e.g. during chdir($HOME) by only matching it at
# the start of the line.
if self.stream.conn.options.password is not None and \
self.password_sent:
self.stream.conn._fail_connection(

@ -58,6 +58,14 @@ class SshTest(testlib.DockerMixin, testlib.TestCase):
expect = "%s: debug1: Reading configuration data" % (context.name,)
self.assertTrue(expect in s)
def test_bash_permission_denied(self):
# issue #271: only match Permission Denied at start of line.
context = self.docker_ssh(
username='mitogen__permdenied',
password='permdenied_password',
ssh_debug_level=3,
)
def test_stream_name(self):
context = self.docker_ssh(
username='mitogen__has_sudo',

Loading…
Cancel
Save