summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2012-10-12 09:41:52 +0200
committerJeff Forcier <jeff@bitprophet.org>2013-04-27 20:36:45 -0700
commit080bece2586d348b9791892cd6e5670a7afdb1a9 (patch)
tree258eb2f4baf7cef9add9df6ce1e841d47f42842b
parent4f481a57a291316e75b0ce0b5f159e66b49ffe3a (diff)
Assure that host entries in known_hosts files do not duplicate endlessly if keys from known_hosts are loaded via HostKeys.load() more than once (e.g. for refreshing the list of known hosts during runtime).
-rw-r--r--paramiko/hostkeys.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py
index da5b66cc..27b9fef0 100644
--- a/paramiko/hostkeys.py
+++ b/paramiko/hostkeys.py
@@ -168,7 +168,12 @@ class HostKeys (UserDict.DictMixin):
continue
e = HostKeyEntry.from_line(line)
if e is not None:
- self._entries.append(e)
+ _hostnames = e.hostnames
+ for h in _hostnames:
+ if self.check(h, e.key):
+ e.hostnames.remove(h)
+ if len(e.hostnames):
+ self._entries.append(e)
f.close()
def save(self, filename):