Commit 642b183f by Michael DeHaan

Use atomic move function on known host file in paramiko to prevent rare occurance of Control-C

during file operations.
parent a7d2e729
...@@ -381,7 +381,13 @@ class Connection(object): ...@@ -381,7 +381,13 @@ class Connection(object):
self.ssh.load_system_host_keys() self.ssh.load_system_host_keys()
self.ssh._host_keys.update(self.ssh._system_host_keys) self.ssh._host_keys.update(self.ssh._system_host_keys)
self._save_ssh_host_keys(self.keyfile)
# save the new keys to a temporary file and move it into place
# rather than rewriting the file
tmp_keyfile = tempfile.NamedTemporaryFile()
self._save_ssh_host_keys(tmp_keyfile)
atomic_move(tmp_keyfile.name, self.keyfile)
tmp_keyfile.close()
except: except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment