patch from gary poster: allow multiple hostnames to be specified per block in the ssh config file format. bug #332382
This commit is contained in:
parent
15f4bdb105
commit
e06dbde805
|
@ -47,7 +47,7 @@ class SSHConfig (object):
|
||||||
@param file_obj: a file-like object to read the config file from
|
@param file_obj: a file-like object to read the config file from
|
||||||
@type file_obj: file
|
@type file_obj: file
|
||||||
"""
|
"""
|
||||||
config = self._config[0]
|
configs = [self._config[0]]
|
||||||
for line in file_obj:
|
for line in file_obj:
|
||||||
line = line.rstrip('\n').lstrip()
|
line = line.rstrip('\n').lstrip()
|
||||||
if (line == '') or (line[0] == '#'):
|
if (line == '') or (line[0] == '#'):
|
||||||
|
@ -66,14 +66,19 @@ class SSHConfig (object):
|
||||||
value = line[i:].lstrip()
|
value = line[i:].lstrip()
|
||||||
|
|
||||||
if key == 'host':
|
if key == 'host':
|
||||||
|
del configs[:]
|
||||||
|
# the value may be multiple hosts, space-delimited
|
||||||
|
for host in value.split():
|
||||||
# do we have a pre-existing host config to append to?
|
# do we have a pre-existing host config to append to?
|
||||||
matches = [c for c in self._config if c['host'] == value]
|
matches = [c for c in self._config if c['host'] == host]
|
||||||
if len(matches) > 0:
|
if len(matches) > 0:
|
||||||
config = matches[0]
|
configs.append(matches[0])
|
||||||
else:
|
else:
|
||||||
config = { 'host': value }
|
config = { 'host': host }
|
||||||
self._config.append(config)
|
self._config.append(config)
|
||||||
|
configs.append(config)
|
||||||
else:
|
else:
|
||||||
|
for config in configs:
|
||||||
config[key] = value
|
config[key] = value
|
||||||
|
|
||||||
def lookup(self, hostname):
|
def lookup(self, hostname):
|
||||||
|
|
Loading…
Reference in New Issue