=OXc@sdZddlZddlZddlZddlZddlTddlmZyddl Z Wne k rddl Z nXddl m Z dZdZd Zd Zd Zejd d krejnejZdejfdYZdZdefdYZdS(sP Functions for communicating with Pageant, the basic windows ssh agent program. iN(t*(tbi(t_winapilPi iJcCs"tjjjtdtdS(NtPageant(tctypestwindlltuser32t FindWindowAR(((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pyt_get_pageant_window_object.scCs ttS(s 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. (tboolR(((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pytcan_talk_to_agent2sit64bittCOPYDATASTRUCTcBs8eZdZdefdejjfdejfgZRS(sy ctypes implementation of http://msdn.microsoft.com/en-us/library/windows/desktop/ms649010%28v=vs.85%29.aspx tnum_datat data_sizetdata_loc( t__name__t __module__t__doc__t ULONG_PTRRtwintypestDWORDtc_void_pt_fields_(((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pyR ?s c Cst}|sdSdtj}tj|ttj}||j|t j dt |t }|j \}}t t||}tjjj|ttj|tj|}|dkr|jd|jd} tjd| d} | |j| SdSWdQXdS(sa Communication with the Pageant process is done through a shared memory-mapped file. sPageantRequest%08xRiis>IN(RtNonetthreadt get_identRt MemoryMapt_AGENT_MAX_MSGLENt get_security_attributes_for_usertwritetarrayRt zero_bytet buffer_infoR t_AGENT_COPYDATA_IDRRRt SendMessageAtwin32con_WM_COPYDATAtsizeoftbyreftseektreadtstructtunpack( tmsgthwndtmap_nametpymapt char_buffertchar_buffer_addresstchar_buffer_sizetcdstresponsetdatalentretlen((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pyt_query_pageantKs(     !  tPageantConnectioncBs2eZdZdZdZdZdZRS(s 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|_dS(N(Rt _response(tself((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pyt__init__wscCst||_dS(N(R6R8(R9tdata((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pytsendzscCsO|jdkrdS|j| }|j||_|jdkrKd|_n|S(Nt(R8R(R9tntret((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pytrecv}s  cCsdS(N((R9((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pytcloses(RRRR:R<R@RA(((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pyR7os    (RRtctypes.wintypesRtplatformR)t paramiko.utiltparamiko.py3compatRt_threadRt ImportErrorR=RR"RR$RR t architecturetc_uint64tc_uint32Rt StructureR R6tobjectR7(((s8/usr/lib/python2.7/site-packages/paramiko/win_pageant.pyts(        ( $