Reorganize forwarded agent cxns to avoid errors

Fixes [Fabric #562](https://github.com/fabric/fabric/issues/562).
(cherry picked from commit 58aa52085b)
This commit is contained in:
Jeff Forcier 2012-05-07 20:09:28 -07:00
parent 1a033dc596
commit 077fdae801
2 changed files with 27 additions and 7 deletions

View File

@ -7,6 +7,12 @@ Temporary, post-Paramiko changelog while we get our sh!t together.
* #24: Switch some internal type checking to use `isinstance` to help prevent
problems with client libraries using subclasses of builtin types. Thanks to
Alex Morega for the patch.
* [Fabric #562](https://github.com/fabric/fabric/issues/562): Agent forwarding
would error out (with `Authentication response too long`) or freeze, when more
than one remote connection to the local agent was active at the same time.
This has been fixed. Thanks to Steven McDonald for assisting in
troubleshooting/patching, and to GitHub user `@lynxis` for providing the
final version of the patch.
## ssh 1.7.13 (2012-02-13)

View File

@ -186,10 +186,11 @@ class AgentClientProxy(object):
the remote fake agent and the local agent
-> Communication occurs ...
"""
def __init__(self, chanClient):
def __init__(self, chanRemote):
self._conn = None
self.__chanC = chanClient
chanClient.request_forward_agent(self._forward_agent_handler)
self.__chanR = chanRemote
self.thread = AgentRemoteProxy(self, chanRemote)
self.thread.start()
def __del__(self):
self.close()
@ -227,10 +228,6 @@ class AgentClientProxy(object):
if self._conn is not None:
self._conn.close()
def _forward_agent_handler(self, chanRemote):
self.thread = AgentRemoteProxy(self, chanRemote)
self.thread.start()
class AgentServerProxy(AgentSSH):
"""
@param t : transport used for the Forward for SSH Agent communication
@ -281,6 +278,23 @@ class AgentServerProxy(AgentSSH):
def _get_filename(self):
return self._file
class AgentRequestHandler(object):
def __init__(self, chanClient):
self._conn = None
self.__chanC = chanClient
chanClient.request_forward_agent(self._forward_agent_handler)
self.__clientProxys = []
def _forward_agent_handler(self, chanRemote):
self.__clientProxys.append(AgentClientProxy(chanRemote))
def __del__(self):
self.close()
def close(self):
for p in self.__clientProxys:
p.close()
class Agent(AgentSSH):
"""
Client interface for using private keys from an SSH agent running on the