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).

This commit is contained in:
Mike Gabriel 2012-10-12 09:41:52 +02:00 committed by Jeff Forcier
parent 4f481a57a2
commit 080bece258
1 changed files with 6 additions and 1 deletions

View File

@ -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):