Reorganize forwarded agent cxns to avoid errors

Fixes [Fabric #562](https://github.com/fabric/fabric/issues/562).
This commit is contained in:
Jeff Forcier 2012-05-07 20:09:28 -07:00
parent 8917d83221
commit 58aa52085b
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 * #24: Switch some internal type checking to use `isinstance` to help prevent
problems with client libraries using subclasses of builtin types. Thanks to problems with client libraries using subclasses of builtin types. Thanks to
Alex Morega for the patch. 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) ## ssh 1.7.13 (2012-02-13)

View File

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