mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Parse OpenSSH versions with no SSH_EXTRAVERSION
If the Debian banner is not used, then there won't be a space after the version number: it'll be followed directly by a comma. Bug: https://crbug.com/gerrit/16903 Change-Id: I12b873f32afc9424f42b772399c346f96ca95a96 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/372875 Tested-by: Saagar Jha <saagarjha@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
551285fa35
commit
90f574f02e
2
ssh.py
2
ssh.py
@ -42,7 +42,7 @@ def _parse_ssh_version(ver_str=None):
|
|||||||
"""parse a ssh version string into a tuple"""
|
"""parse a ssh version string into a tuple"""
|
||||||
if ver_str is None:
|
if ver_str is None:
|
||||||
ver_str = _run_ssh_version()
|
ver_str = _run_ssh_version()
|
||||||
m = re.match(r"^OpenSSH_([0-9.]+)(p[0-9]+)?\s", ver_str)
|
m = re.match(r"^OpenSSH_([0-9.]+)(p[0-9]+)?[\s,]", ver_str)
|
||||||
if m:
|
if m:
|
||||||
return tuple(int(x) for x in m.group(1).split("."))
|
return tuple(int(x) for x in m.group(1).split("."))
|
||||||
else:
|
else:
|
||||||
|
@ -39,6 +39,8 @@ class SshTests(unittest.TestCase):
|
|||||||
"OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\n"
|
"OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\n"
|
||||||
)
|
)
|
||||||
self.assertEqual(ver, (7, 6))
|
self.assertEqual(ver, (7, 6))
|
||||||
|
ver = ssh._parse_ssh_version("OpenSSH_9.0p1, LibreSSL 3.3.6\n")
|
||||||
|
self.assertEqual(ver, (9, 0))
|
||||||
|
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
"""Check version() handling."""
|
"""Check version() handling."""
|
||||||
|
Loading…
Reference in New Issue
Block a user