summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2014-11-12 13:52:28 +0000
committerDaniel Watkins <daniel.watkins@canonical.com>2014-11-12 13:52:28 +0000
commit4ecca95e5973707f08fefc43448fec9e0f984966 (patch)
treed80e2776352759c954fdc2a39ad3ddfcc3f09114
parentbd462bc68506d7da4d7e04b05e947e0cf3f8e19d (diff)
downloadvyos-cloud-init-4ecca95e5973707f08fefc43448fec9e0f984966.tar.gz
vyos-cloud-init-4ecca95e5973707f08fefc43448fec9e0f984966.zip
Handle = used as config delimiter in SSH config.
-rw-r--r--cloudinit/ssh_util.py5
-rw-r--r--tests/unittests/test_sshutil.py14
2 files changed, 18 insertions, 1 deletions
diff --git a/cloudinit/ssh_util.py b/cloudinit/ssh_util.py
index 70a577bc..14d0cb0f 100644
--- a/cloudinit/ssh_util.py
+++ b/cloudinit/ssh_util.py
@@ -293,7 +293,10 @@ def parse_ssh_config(fname):
if not line or line.startswith("#"):
lines.append(SshdConfigLine(line))
continue
- (key, val) = line.split(None, 1)
+ try:
+ key, val = line.split(None, 1)
+ except ValueError:
+ key, val = line.split('=', 1)
lines.append(SshdConfigLine(line, key, val))
return lines
diff --git a/tests/unittests/test_sshutil.py b/tests/unittests/test_sshutil.py
index 2a496418..cd576e8f 100644
--- a/tests/unittests/test_sshutil.py
+++ b/tests/unittests/test_sshutil.py
@@ -154,4 +154,18 @@ class TestParseSSHConfig(TestCase):
self.assertEqual('foo', ret[0].key)
self.assertEqual('Bar', ret[0].value)
+ def test_lower_case_with_equals(self):
+ self.load_file.return_value = 'foo=bar'
+ ret = ssh_util.parse_ssh_config('some real file')
+ self.assertEqual(1, len(ret))
+ self.assertEqual('foo', ret[0].key)
+ self.assertEqual('bar', ret[0].value)
+
+ def test_upper_case_with_equals(self):
+ self.load_file.return_value = 'Foo=bar'
+ ret = ssh_util.parse_ssh_config('some real file')
+ self.assertEqual(1, len(ret))
+ self.assertEqual('foo', ret[0].key)
+ self.assertEqual('bar', ret[0].value)
+
# vi: ts=4 expandtab