summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohn Adams <jna@twitter.com>2011-02-01 02:43:17 -0800
committerJohn Adams <jna@twitter.com>2011-02-01 02:43:17 -0800
commit33fd998a94fc94fa8e1c7ade07951a9cd5e10fbb (patch)
treeebb57d9f146843a88fdab33da483d023040a1a2f
parente2add909811956b4a5cd91d290a3df45612ba75d (diff)
patch ssh-agent handling to not leak file descriptors
-rw-r--r--paramiko/client.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/paramiko/client.py b/paramiko/client.py
index c4cf6964..4a65477d 100644
--- a/paramiko/client.py
+++ b/paramiko/client.py
@@ -123,6 +123,7 @@ class SSHClient (object):
self._log_channel = None
self._policy = RejectPolicy()
self._transport = None
+ self._agent = None
def load_system_host_keys(self, filename=None):
"""
@@ -339,6 +340,10 @@ class SSHClient (object):
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
@@ -436,7 +441,10 @@ class SSHClient (object):
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)