ó =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|tƒst‚t|ƒ}|j||jkrJtd|ƒ‚n|j|j}tj |ƒ}tj j j |||ƒ|j|7_dS(NsRefusing to write %d bytes( t isinstanceRtAssertionErrortlenR2R0t 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_bufferR7R2RBRRRCtraw(R REtoutRR0((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=RGRKRQ(((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.pyRRÿstTokenInformationClasscBseZdZRS(i(R)R*t TokenUser(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRTst TOKEN_USERcBs/eZdZdejfdejjfgZRS(itSIDt ATTRIBUTES(R)R*tnumRtc_void_pRtDWORDt_fields_(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRVs 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_ubyteRZR\(((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(RRiRRtsizeofRj(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(RoRt addressofRk(R R ((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRp=s ( R)R*R+RRR[RZtBOOLR\RR,Rptsetter(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRi'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(RRR[Rtadvapi32tGetTokenInformationRYR RHR R RmtcasttPOINTERRVtcontents(ttokentinformation_classt data_sizetdata((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyRuLscCsMtjjƒ}tjj|ƒ}ttjjj||tj|ƒƒƒ|S(N(RRtHANDLER RRttOpenProcessTokenR (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~RRRtGetCurrentProcessRRRSRuRV(tprocess((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pytget_current_useras cCs¢|dkrtƒ}nt|tƒs3tdƒ‚tƒ}tƒ}||_d|_t j j j t j |ƒtjƒt j j jt j |ƒ|jdƒ|S(s… Return a SECURITY_ATTRIBUTES structure with the SID set to the specified user (uses current user if none is specified). s user must be TOKEN_USER instanceiiN(RRƒR>RVR?R]RiRpRlRRRttInitializeSecurityDescriptorR RgtSetSecurityDescriptorOwnerRW(tusertSDtSA((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyt get_security_attributes_for_userks        (((KR+Rtctypes.wintypesRtparamiko.py3compatRRRRR t GMEM_MOVEABLERRt GlobalAllocRtUINTRBtargtypesR}trestypet GlobalLocktHGLOBALtLPVOIDt GlobalUnlockRrt GlobalSizeR3tCreateFileMappingRZR[RR6RLRCtHLOCALR 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_EXECUTERRRTt StructureRVR]RiRwRtR…RuR~RƒRR‰(((s4/usr/lib/python2.7/site-packages/paramiko/_winapi.pyts˜   $      </