From afae8dd7c59dbe2d1b3f8650d6f826290de306cb Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Mon, 23 May 2011 13:40:33 -0700 Subject: [PATCH] oops. fix potential exception when there's no ssh agent available. --- paramiko/agent.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paramiko/agent.py b/paramiko/agent.py index 67d58c4..3bb9426 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -55,6 +55,7 @@ class Agent: @raise SSHException: if an SSH agent is found, but speaks an incompatible protocol """ + self.conn = None self.keys = () if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'): conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) @@ -87,7 +88,8 @@ class Agent: """ Close the SSH agent connection. """ - self.conn.close() + if self.conn is not None: + self.conn.close() self.conn = None self.keys = ()