a b@sdZddlZddlZddlZddlZddlmZddlm Z z ddl Z Wne ybddl Z Yn0ddl mZdZdZd Zd d Zd d ZeddkrejZnejZGdddejZddZGdddeZdS)zP Functions for communicating with Pageant, the basic windows ssh agent program. N) zero_byte)b)_winapilPi JcCstjjddS)NsPageant)ctypeswindlluser32Z FindWindowAr r ;/tmp/pip-target-98j97qn4/lib/python/paramiko/win_pageant.py_get_pageant_window_object.sr cCs ttS)z Check to see if there is a "Pageant" agent we can talk to. This checks both if we have the required libraries (win32all or ctypes) and if there is a Pageant currently running. )boolr r r r r can_talk_to_agent2sr64bitc@s,eZdZdZdefdejjfdejfgZ dS)COPYDATASTRUCTzy ctypes implementation of http://msdn.microsoft.com/en-us/library/windows/desktop/ms649010%28v=vs.85%29.aspx Znum_data data_sizeZdata_locN) __name__ __module__ __qualname____doc__ ULONG_PTRrZwintypesZDWORDc_void_p_fields_r r r r rBs  rc Cst}|sdSdt}t|tt}|||tdt |t }| \}}t t ||}tjj|tt|t|}|dkr|d|d} td| d} | || WdSWddS1s0YdS)za Communication with the Pageant process is done through a shared memory-mapped file. NzPageantRequest%08xrrz>I)r thread get_identrZ MemoryMap_AGENT_MAX_MSGLENZ get_security_attributes_for_userwritearrayrr buffer_infor_AGENT_COPYDATA_IDrrr Z SendMessageAwin32con_WM_COPYDATAsizeofbyrefseekreadstructunpack) msgZhwndZmap_nameZpymapZ char_bufferZchar_buffer_addressZchar_buffer_sizeZcdsresponseZdatalenZretlenr r r _query_pageantOs.      r*c@s0eZdZdZddZddZddZdd Zd S) PageantConnectiona Mock "connection" to an agent which roughly approximates the behavior of a unix local-domain socket (as used by Agent). Requests are sent to the pageant daemon via special Windows magick, and responses are buffered back for subsequent reads. cCs d|_dSN _responseselfr r r __init__}szPageantConnection.__init__cCst||_dSr,)r*r.)r0datar r r sendszPageantConnection.sendcCs@|jdurdS|jd|}|j|d|_|jdkrs,       &