summaryrefslogtreecommitdiff
path: root/paramiko/config.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-09-05 13:23:02 -0700
committerJeff Forcier <jeff@bitprophet.org>2014-09-05 13:23:02 -0700
commit0e784d81131a369da88051e4c12dd6e4b5e3c8b1 (patch)
tree4bec5f731196ced01797d11548dde6ca84f22c9e /paramiko/config.py
parentf258d1e207a21d4342dbc431fcc4a4dafe893e80 (diff)
parent720806734a05d9de0f47588d816de05646a06f0b (diff)
downloadparamiko-0e784d81131a369da88051e4c12dd6e4b5e3c8b1.tar.gz
Merge branch 'master' into 184-int
Conflicts: paramiko/config.py tests/test_util.py
Diffstat (limited to 'paramiko/config.py')
-rw-r--r--paramiko/config.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/paramiko/config.py b/paramiko/config.py
index 5abf181f..20ca4aa7 100644
--- a/paramiko/config.py
+++ b/paramiko/config.py
@@ -57,8 +57,8 @@ class SSHConfig (object):
host = {"host": ['*'], "config": {}}
for line in file_obj:
- line = line.rstrip('\n').lstrip()
- if (line == '') or (line[0] == '#'):
+ line = line.rstrip('\r\n').lstrip()
+ if not line or line.startswith('#'):
continue
match = re.match(self.SETTINGS_REGEX, line)
@@ -107,8 +107,10 @@ class SSHConfig (object):
:param str hostname: the hostname to lookup
"""
- matches = [config for config in self._config if
- self._allowed(hostname, config['host'])]
+ matches = [
+ config for config in self._config
+ if self._allowed(config['host'], hostname)
+ ]
ret = {}
for match in matches:
@@ -124,7 +126,7 @@ class SSHConfig (object):
ret = self._expand_variables(ret, hostname)
return ret
- def _allowed(self, hostname, hosts):
+ def _allowed(self, hosts, hostname):
match = False
for host in hosts:
if host.startswith('!') and fnmatch.fnmatch(hostname, host[1:]):
@@ -196,10 +198,12 @@ class SSHConfig (object):
for find, replace in replacements[k]:
if isinstance(config[k], list):
for item in range(len(config[k])):
- config[k][item] = config[k][item].\
- replace(find, str(replace))
+ if find in config[k][item]:
+ config[k][item] = config[k][item].\
+ replace(find, str(replace))
else:
- config[k] = config[k].replace(find, str(replace))
+ if find in config[k]:
+ config[k] = config[k].replace(find, str(replace))
return config
def _get_hosts(self, host):