%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/utils/win_runas.pyo

�
���^c@@s\dZddlmZmZddlZddlZddlZyddlZeZ	Wne
k
roeZ	nXy�ddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZeZWne
k
reZnXddlmZeje�Zd�Zd�Zddd�Z dd�Z!dS(	u.
Run processes as a different user in Windows
i(tabsolute_importtunicode_literalsN(tCommandExecutionErrorcC@ststrtdfSdS(u4
    Only load if Win32 Libraries are installed
    u(This utility requires pywin32 and psutilu	win_runas(t	HAS_WIN32t
HAS_PSUTILtFalse(((s8/usr/lib/python2.7/site-packages/salt/utils/win_runas.pyt__virtual__*s
cC@sXd}d|kr*|jd�\}}nd|krN|jd�\}}n||fS(Nu.u@u\(tsplit(tusernametdomain((s8/usr/lib/python2.7/site-packages/salt/utils/win_runas.pytsplit_username4sc$C@s"t|�\}}ytj||�\}}}Wn=tjk
rp}tj|j�jd�}t	|��nXtj
tjB}tjtj
�|�}	tjjj|	�y1tjjjtjjjddddg�}
Wn1tk
rtjd�d}
tj|	�nX|
s7tjd�t||||�S|dkrgtj||d	tjtj�}nB|r�tj|||tjtj�}ntjjj|�j }tj!|tj"�}|d
kr�tj!|tj#�}ntjjj|�tjjj$|�tj%�}
d
|
_&t'j(|
d�\}}tjjj)|�}t'j(|
d�\}}tjjj)|�}t'j(|
d�\}}tjjj)|�}t*j+t*j,Bt*j-B}tjjj.dtj/d|j0d
|j0d|j0�}t1j2|t3�}d}z�tjjj4t5|�dd
ddd|d|d|d|d|�}|j6}|j7}|j8}|j9}tjjj:j|j0�tjjj:j|j0�tjjj:j|j0�i|d6}t;j<|�j=�t>j?|t>j@�tjAkrt*jB|�}||d<ntCjD|j0tEjFtEjGB�}tEjH|d��}|jI�} | |d<WdQXtCjD|j0tEjFtEjGB�}!tEjH|!d��}"|"jI�}#|#|d<WdQXWd|dk	r�tjjj:j|�ntj|	�tj|�|
rtjJ�ntj|
�X|S(uB
    Run a command as another user. If the process is running as an admin or
    system account this method does not require a password. Other non
    privileged accounts need to provide a password for the user to runas.
    Commands are run in with the highest level privileges possible for the
    account provided.
    u
t
session_iditprivsuSeTcbPrivilegeu!Unable to impersonate SYSTEM useru0No impersonation token, using unprivileged runasuNT AUTHORITYuitdwFlagst	hStdInputt
hStdOutputt	hStdErrort
logonflagstapplicationnametcommandlinetcurrentdirectoryt
creationflagststartupinfotenvironmentupiduretcodeurustdoutNustderr(KR
t
win32securitytLookupAccountNamet
pywintypesterrortwin32apit
FormatMessagetwinerrortrstripRtTOKEN_QUERYtTOKEN_ADJUST_PRIVILEGEStOpenProcessTokentGetCurrentProcesstsalttplatformtwint
elevate_tokentimpersonate_sidt
SYSTEM_SIDtWindowsErrortlogtdebugtNonetCloseHandletrunas_unprivt	LogonUsertwin32contLOGON32_LOGON_SERVICEtLOGON32_PROVIDER_DEFAULTtLOGON32_LOGON_INTERACTIVEtlogon_msv1_s4utTokentGetTokenInformationtTokenElevationTypetTokenLinkedTokentgrant_winsta_and_desktoptSECURITY_ATTRIBUTEStbInheritHandlet	win32pipet
CreatePipetmake_inheritabletwin32processtCREATE_NO_WINDOWtCREATE_NEW_CONSOLEtCREATE_SUSPENDEDtSTARTUPINFOtSTARTF_USESTDHANDLESthandletwin32profiletCreateEnvironmentBlockRtCreateProcessWithTokenWtintthProcessthThreadtdwProcessIdt
dwThreadIdtkernel32tpsutiltProcesstresumet
win32eventtWaitForSingleObjecttINFINITEt
WAIT_OBJECT_0tGetExitCodeProcesstmsvcrttopen_osfhandletostO_RDONLYtO_TEXTtfdopentreadtRevertToSelf($tcmdLineRtpasswordtcwdR	t_texctmessagetaccesstthtimpersonation_tokent
user_tokentelevation_typetsecurity_attributest
stdin_readtstdin_writetstdout_readtstdout_writetstderr_readtstderr_writeRtstartup_infotenvRKtprocess_infoRLRMRNtrettexitcodetfd_outtf_outtstdouttfd_errtf_errtstderr((s8/usr/lib/python2.7/site-packages/salt/utils/win_runas.pytrunas>s�	



	

								




cC@s�t|�\}}ytj||�\}}}Wn=tjk
rp}tj|j�jd�}t	|��nXt
jjj
dtdt�\}}	t
jjj
dtdt�\}
}t
jjjjt
jjj�}t
jjjd|dt�}
t
jjjdtjd|
d|	d	|�}zbt
jjjd
|d|d|d
t
jjjd|d|d|�}t
jjjj|j�Wdt
jjjj|
�t
jjjj|	�t
jjjj|�Xi|jd6}tj|tjtj B�}tj!|d��}|j"�|d<WdQXtj|
tjtj B�}tj!|d��}|j"�|d<WdQXt
jjjj#|j$t%j&�tj'kr�t
jjj(j)�}t
jjjj*|j$t+j,|��|j-|d<nt
jjjj|j$�|S(u4
    Runas that works for non-priviledged users
    u
tinherit_readt
inherit_writet	srchandletinheritR
RRRRR	RaRRRRNupidurustdoutustderruretcode(.R
RRRRRRRRRR$R%R&R>RtTrueROtGetStdHandletSTD_INPUT_HANDLEtDuplicateHandleRDR1REtCreateProcessWithLogonWtLOGON_WITH_PROFILER.RLRMRXRYRZR[R\R]R^RTRKRSRURVtwintypestDWORDRWtctypestbyreftvalue(tcmdRRaRbR	RcRdRetc2preadtc2pwriteterrreadterrwritetstdintdupinRrRtRuRwRxRzR{Rv((s8/usr/lib/python2.7/site-packages/salt/utils/win_runas.pyR/�s\			("t__doc__t
__future__RRR�RZtloggingRPR�RtImportErrorRRR1R@RR=RSRGRXtsalt.platform.winR$RRtsalt.exceptionsRt	getLoggert__name__R+RR
R-R}R/(((s8/usr/lib/python2.7/site-packages/salt/utils/win_runas.pyt<module>s:





	
	
�

Zerion Mini Shell 1.0