Skip to content

Commit

Permalink
patch ssh-agent handling to not leak file descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
John Adams committed Feb 1, 2011
1 parent e2add90 commit 33fd998
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion paramiko/client.py
Expand Up @@ -123,6 +123,7 @@ def __init__(self):
self._log_channel = None
self._policy = RejectPolicy()
self._transport = None
self._agent = None

def load_system_host_keys(self, filename=None):
"""
Expand Down Expand Up @@ -339,6 +340,10 @@ def close(self):
self._transport.close()
self._transport = None

if self._agent != None:
self._agent.close()
self._agent = None

def exec_command(self, command, bufsize=-1):
"""
Execute a command on the SSH server. A new L{Channel} is opened and
Expand Down Expand Up @@ -436,7 +441,10 @@ def _auth(self, username, password, pkey, key_filenames, allow_agent, look_for_k
saved_exception = e

if allow_agent:
for key in Agent().get_keys():
if self._agent == None:
self._agent = Agent()

for key in self._agent.get_keys():
try:
self._log(DEBUG, 'Trying SSH agent key %s' % hexlify(key.get_fingerprint()))
self._transport.auth_publickey(username, key)
Expand Down

0 comments on commit 33fd998

Please sign in to comment.