Whitespace tweaks, thanks @jaraco
This commit is contained in:
parent
ec2aedac71
commit
3b20efcc14
18
ssh/agent.py
18
ssh/agent.py
|
@ -45,7 +45,7 @@ class AgentSSH(object):
|
||||||
local machine. If an SSH agent is running, this class can be used to
|
local machine. If an SSH agent is running, this class can be used to
|
||||||
connect to it and retreive L{PKey} objects which can be used when
|
connect to it and retreive L{PKey} objects which can be used when
|
||||||
attempting to authenticate to remote SSH servers.
|
attempting to authenticate to remote SSH servers.
|
||||||
|
|
||||||
Because the SSH agent protocol uses environment variables and unix-domain
|
Because the SSH agent protocol uses environment variables and unix-domain
|
||||||
sockets, this probably doesn't work on Windows. It does work on most
|
sockets, this probably doesn't work on Windows. It does work on most
|
||||||
posix platforms though (Linux and MacOS X, for example).
|
posix platforms though (Linux and MacOS X, for example).
|
||||||
|
@ -59,7 +59,7 @@ class AgentSSH(object):
|
||||||
Return the list of keys available through the SSH agent, if any. If
|
Return the list of keys available through the SSH agent, if any. If
|
||||||
no SSH agent was running (or it couldn't be contacted), an empty list
|
no SSH agent was running (or it couldn't be contacted), an empty list
|
||||||
will be returned.
|
will be returned.
|
||||||
|
|
||||||
@return: a list of keys available on the SSH agent
|
@return: a list of keys available on the SSH agent
|
||||||
@rtype: tuple of L{AgentKey}
|
@rtype: tuple of L{AgentKey}
|
||||||
"""
|
"""
|
||||||
|
@ -195,7 +195,7 @@ class AgentClientProxy(object):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""
|
"""
|
||||||
Method automatically called by the run() method of the AgentProxyThread
|
Method automatically called by the run() method of the AgentProxyThread
|
||||||
"""
|
"""
|
||||||
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
|
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
|
||||||
|
@ -274,7 +274,7 @@ class AgentServerProxy(AgentSSH):
|
||||||
@return: the SSH_AUTH_SOCK Environnement variables
|
@return: the SSH_AUTH_SOCK Environnement variables
|
||||||
@rtype: dict
|
@rtype: dict
|
||||||
"""
|
"""
|
||||||
env = {}
|
env = {}
|
||||||
env['SSH_AUTH_SOCK'] = self._get_filename()
|
env['SSH_AUTH_SOCK'] = self._get_filename()
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
@ -287,18 +287,18 @@ class Agent(AgentSSH):
|
||||||
local machine. If an SSH agent is running, this class can be used to
|
local machine. If an SSH agent is running, this class can be used to
|
||||||
connect to it and retreive L{PKey} objects which can be used when
|
connect to it and retreive L{PKey} objects which can be used when
|
||||||
attempting to authenticate to remote SSH servers.
|
attempting to authenticate to remote SSH servers.
|
||||||
|
|
||||||
Because the SSH agent protocol uses environment variables and unix-domain
|
Because the SSH agent protocol uses environment variables and unix-domain
|
||||||
sockets, this probably doesn't work on Windows. It does work on most
|
sockets, this probably doesn't work on Windows. It does work on most
|
||||||
posix platforms though (Linux and MacOS X, for example).
|
posix platforms though (Linux and MacOS X, for example).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Open a session with the local machine's SSH agent, if one is running.
|
Open a session with the local machine's SSH agent, if one is running.
|
||||||
If no agent is running, initialization will succeed, but L{get_keys}
|
If no agent is running, initialization will succeed, but L{get_keys}
|
||||||
will return an empty tuple.
|
will return an empty tuple.
|
||||||
|
|
||||||
@raise SSHException: if an SSH agent is found, but speaks an
|
@raise SSHException: if an SSH agent is found, but speaks an
|
||||||
incompatible protocol
|
incompatible protocol
|
||||||
"""
|
"""
|
||||||
|
@ -320,7 +320,7 @@ class Agent(AgentSSH):
|
||||||
else:
|
else:
|
||||||
# no agent support
|
# no agent support
|
||||||
return
|
return
|
||||||
self._connect(conn)
|
self._connect(conn)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
|
@ -334,7 +334,7 @@ class AgentKey(PKey):
|
||||||
authenticating to a remote server (signing). Most other key operations
|
authenticating to a remote server (signing). Most other key operations
|
||||||
work as expected.
|
work as expected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, agent, blob):
|
def __init__(self, agent, blob):
|
||||||
self.agent = agent
|
self.agent = agent
|
||||||
self.blob = blob
|
self.blob = blob
|
||||||
|
|
|
@ -42,7 +42,6 @@ except ImportError:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
_AGENT_COPYDATA_ID = 0x804e50ba
|
_AGENT_COPYDATA_ID = 0x804e50ba
|
||||||
_AGENT_MAX_MSGLEN = 8192
|
_AGENT_MAX_MSGLEN = 8192
|
||||||
# Note: The WM_COPYDATA value is pulled from win32con, as a workaround
|
# Note: The WM_COPYDATA value is pulled from win32con, as a workaround
|
||||||
|
@ -108,7 +107,7 @@ def _query_pageant(msg):
|
||||||
response = ctypes.windll.user32.SendMessageA(hwnd, win32con_WM_COPYDATA, _size, _addr)
|
response = ctypes.windll.user32.SendMessageA(hwnd, win32con_WM_COPYDATA, _size, _addr)
|
||||||
else:
|
else:
|
||||||
response = 0
|
response = 0
|
||||||
|
|
||||||
if response > 0:
|
if response > 0:
|
||||||
datalen = pymap.read(4)
|
datalen = pymap.read(4)
|
||||||
retlen = struct.unpack('>I', datalen)[0]
|
retlen = struct.unpack('>I', datalen)[0]
|
||||||
|
@ -131,10 +130,10 @@ class PageantConnection (object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._response = None
|
self._response = None
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
self._response = _query_pageant(data)
|
self._response = _query_pageant(data)
|
||||||
|
|
||||||
def recv(self, n):
|
def recv(self, n):
|
||||||
if self._response is None:
|
if self._response is None:
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in New Issue