ó =OXc@sÏdZddlZddlZddlmZmZd„Zdejfd„ƒYZd„Z dZ ej j j Z ejjejfe _ejje _ej j jZejjfe_ejje_ej j jZejjfe_ejje_ej j jZejjfe_eje_ej j jZejjejejjejjejjejjge_ejje_ej j jZejje_ej j j Z ejjfe _ej j j!Z!ejejejfe!_ejj"fej j j#_d e$fd „ƒYZ%d Z&d Z'e&Z(e&Z)e&Z*d Z+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8e'e,Be-Be.Be/Be0Be1Be2Be3Be4Be5Be6Be7BZ9e(e-Be.BZ:e)e/Be0Be1Be2Be3Be4Be5Be6BZ;e*e,Be7BZ<dd(d„ƒYZ=dd)d„ƒYZ>dej?fd„ƒYZ@d ej?fd!„ƒYZAd"ej?fd#„ƒYZBejCeAƒejejjfej jDjE_d$„ZFd%„ZGd&„ZHdd'„ZJdS(*sü Windows API functions implemented as ctypes functions and classes as found in jaraco.windows (3.4.1). If you encounter issues with this module, please consider reporting the issues in jaraco.windows and asking the author to port the fixes back here. iÿÿÿÿN(tutbuiltinsc Csd}d}||B}d}|}d}tjjƒ}d}d} tjjj||||tj|ƒ|| ƒ} t| ƒ|j } tjjj |ƒ| S(sf Call FormatMessage with a system error number to retrieve the descriptive error message. iiiN( tNonetctypestwintypestLPWSTRtwindlltkernel32tFormatMessageWtbyrefthandle_nonzero_successtvaluet LocalFree( terrnotALLOCATE_BUFFERt FROM_SYSTEMtflagstsourcet message_idt language_idt result_buffert buffer_sizet argumentstbytestmessage((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytformat_system_messages*      t WindowsErrorcBsJeZdZdd„Zed„ƒZed„ƒZd„Zd„Z RS(sVmore info about errors at http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspxcCsw|dkr!tjjjƒ}nt|ƒ}tjdkrQd|d|f}n ||f}tt |ƒj |ŒdS(Nii(ii( RRRRt GetLastErrorRtsyst version_infotsuperRt__init__(tselfR tstrerrortargs((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR9s   cCs|jS(N(R!(R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRCscCs|jS(N(twinerror(R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytcodeGscCs|jS(N(R(R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt__str__KscCsdjtƒS(Ns*{self.__class__.__name__}({self.winerror})(tformattvars(R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt__repr__NsN( t__name__t __module__t__doc__RRtpropertyRR$R%R((((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR6s   cCs|dkrtƒ‚ndS(Ni(R(tresult((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR Qs it MemoryMapcBsGeZdZdd„Zd„Zd„Zd„Zd„Zd„Z RS(sL A memory map object which can have security attributes overridden. cCs(||_||_||_d|_dS(Ni(tnametlengthtsecurity_attributestpos(R R/R0R1((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRŒs   cCs°|jrtj|jƒnd}d}d}d}tjjj|||d|jt|j ƒƒ}t |ƒ||krˆt dƒ‚n||_ t ||dddƒ|_|S(NiÿÿÿÿiiisFailed to create file mapping(R1RR RRRtCreateFileMappingWR0RR/R t Exceptiontfilemapt MapViewOfFiletview(R tp_SAtINVALID_HANDLE_VALUEtPAGE_READWRITEtFILE_MAP_WRITER5((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt __enter__’s!    cCs ||_dS(N(R2(R R2((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytseek¤scCs€t|ƒ}|j||jkr5td|ƒ‚n|j|j}tj|ƒ}tjjj |||ƒ|j|7_dS(NsRefusing to write %d bytes( tlenR2R0t ValueErrorR7Rtc_size_tRRt RtlMoveMemory(R tmsgtntdestR0((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytwrite§s cCs]tj|ƒ}|j|j}tj|ƒ}tjjj|||ƒ|j|7_|jS(s0 Read n bytes from mapped view. ( Rtcreate_string_bufferR7R2R@RRRAtraw(R RCtoutRR0((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytread±s cCs0tjjj|jƒtjjj|jƒdS(N(RRRtUnmapViewOfFileR7t CloseHandleR5(R texc_typetexc_valttb((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt__exit__¼sN( R)R*R+RRR<R=RERIRO(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR.ˆs    iiiiiiii i@i€iiiiit TokenAccesscBseZdZRS(i(R)R*t TOKEN_QUERY(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRPÿstTokenInformationClasscBseZdZRS(i(R)R*t TokenUser(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRRst TOKEN_USERcBs/eZdZdejfdejjfgZRS(itSIDt ATTRIBUTES(R)R*tnumRtc_void_pRtDWORDt_fields_(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRTs tSECURITY_DESCRIPTORcBsweZdZejjZdZdejfdejfdefdej fdej fdej fdej fgZ RS( sÿ typedef struct _SECURITY_DESCRIPTOR { UCHAR Revision; UCHAR Sbz1; SECURITY_DESCRIPTOR_CONTROL Control; PSID Owner; PSID Group; PACL Sacl; PACL Dacl; } SECURITY_DESCRIPTOR; itRevisiontSbz1tControltOwnertGrouptSacltDacl( R)R*R+RRtUSHORTtSECURITY_DESCRIPTOR_CONTROLtREVISIONtc_ubyteRXRZ(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR[ s        tSECURITY_ATTRIBUTEScBsheZdZdejjfdejfdejjfgZd„Z e d„ƒZ e j d„ƒZ RS(s¦ typedef struct _SECURITY_ATTRIBUTES { DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; } SECURITY_ATTRIBUTES; tnLengthtlpSecurityDescriptortbInheritHandlecOs/tt|ƒj||Žtjtƒ|_dS(N(RRgRRtsizeofRh(R R"tkwargs((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR5scCs|jS(N(t _descriptor(R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt descriptor9scCs||_tj|ƒ|_dS(N(RmRt addressofRi(R R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRn=s ( R)R*R+RRRYRXtBOOLRZRR,Rntsetter(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRg's  cCs«tjjƒ}tjjj||jddtj|ƒƒtj|j ƒ}t tjjj||jtj|ƒtj |ƒtj|ƒƒƒtj |tj tƒƒjS(s: Given a token, get the token information for it. i(RRRYRtadvapi32tGetTokenInformationRWR RFR R RktcasttPOINTERRTtcontents(ttokentinformation_classt data_sizetdata((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRsLscCsMtjjƒ}tjj|ƒ}ttjjj||tj|ƒƒƒ|S(N(RRtHANDLER RRrtOpenProcessTokenR (t proc_handletaccessR-((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyR|Zs cCs+ttjjjƒtjƒ}t|tƒS(s< Return a TOKEN_USER for the owner of this process. ( R|RRRtGetCurrentProcessRPRQRsRT(tprocess((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytget_current_useras cCs‡|dkrtƒ}ntƒ}tƒ}||_d|_tjjj tj |ƒtj ƒtjjj tj |ƒ|j dƒ|S(s… Return a SECURITY_ATTRIBUTES structure with the SID set to the specified user (uses current user if none is specified). iiN(RRR[RgRnRjRRRrtInitializeSecurityDescriptorR RetSetSecurityDescriptorOwnerRU(tusertSDtSA((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt get_security_attributes_for_userks        (((KR+Rtctypes.wintypesRtparamiko.py3compatRRRRR t GMEM_MOVEABLERRt GlobalAllocRtUINTR@targtypesR{trestypet GlobalLocktHGLOBALtLPVOIDt GlobalUnlockRpt GlobalSizeR3tCreateFileMappingRXRYRR6RJRAtHLOCALR tobjectR.t READ_CONTROLtSTANDARD_RIGHTS_REQUIREDtSTANDARD_RIGHTS_READtSTANDARD_RIGHTS_WRITEtSTANDARD_RIGHTS_EXECUTEtSTANDARD_RIGHTS_ALLtPOLICY_VIEW_LOCAL_INFORMATIONtPOLICY_VIEW_AUDIT_INFORMATIONtPOLICY_GET_PRIVATE_INFORMATIONtPOLICY_TRUST_ADMINtPOLICY_CREATE_ACCOUNTtPOLICY_CREATE_SECRETtPOLICY_CREATE_PRIVILEGEtPOLICY_SET_DEFAULT_QUOTA_LIMITStPOLICY_SET_AUDIT_REQUIREMENTStPOLICY_AUDIT_LOG_ADMINtPOLICY_SERVER_ADMINtPOLICY_LOOKUP_NAMEStPOLICY_NOTIFICATIONtPOLICY_ALL_ACCESSt POLICY_READt POLICY_WRITEtPOLICY_EXECUTERPRRt StructureRTR[RgRuRrRƒRsR|RRR‡(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyts˜   $      </