%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/client/ssh/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/client/ssh/__init__.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$Zddl%Zddl&Zddl'Zddl(Zddl)Zddl*Zddl+Zddl,Zddl-Zddl.m/Z/ddl0m1Z1ddlZddl2m3Z3ddl4m5Z5ddl6m7Z7yddl8Z8e9Z:Wne;k
r�e<Z:nXdd	l=m>Z>d
Z?dZ@de@d
ZAdjBgdjCdejDjEjF�jGd�D]ZHeHjI�^q��ZJe/�r�e
jKjBe
jKjLeM�d�ZNe
jKjOeN�rUeNd7ZNnejPjQjReN��ZSeSjT�ZUWdQXnejVeW�ZXdeYfd��YZZdeYfd��YZ[d�Z\d�Z]d�Z^d�Z_d�Z`dS(u
Create ssh executor system
i(tabsolute_importtprint_functiontunicode_literalsN(t
is_windows(tMultiprocessingProcess(tcompile_template(tsix(tinput(tzmqu$/var/tmp/.%%USER%%_%%FQDNUUID%%_saltuA_edbc7885e4f9aac9b83b35999b68d015148caf467b78fa39c05f669c0ff89878u(?:^|\r?\n)u(?:\r?\n|$)u
uv/bin/sh << 'EOF'
set -e
set -u
DEBUG="{{DEBUG}}"
if [ -n "$DEBUG" ]
    then set -x
fi
SUDO=""
if [ -n "{{SUDO}}" ]
    then SUDO="sudo "
fi
SUDO_USER="{{SUDO_USER}}"
if [ "$SUDO" ] && [ "$SUDO_USER" ]
then SUDO="sudo -u {{SUDO_USER}}"
elif [ "$SUDO" ] && [ -n "$SUDO_USER" ]
then SUDO="sudo "
fi
EX_PYTHON_INVALID={EX_THIN_PYTHON_INVALID}
PYTHON_CMDS="python3 python27 python2.7 python26 python2.6 python2 python"
for py_cmd in $PYTHON_CMDS
do
    if command -v "$py_cmd" >/dev/null 2>&1 && "$py_cmd" -c "import sys; sys.exit(not (sys.version_info >= (2, 6)));"
    then
        py_cmd_path=`"$py_cmd" -c 'from __future__ import print_function;import sys; print(sys.executable);'`
        cmdpath=`command -v $py_cmd 2>/dev/null || which $py_cmd 2>/dev/null`
        if file $cmdpath | grep "shell script" > /dev/null
        then
            ex_vars="'PATH', 'LD_LIBRARY_PATH', 'MANPATH', \
                   'XDG_DATA_DIRS', 'PKG_CONFIG_PATH'"
            export `$py_cmd -c \
                  "from __future__ import print_function;
                  import sys;
                  import os;
                  map(sys.stdout.write, ['{{{{0}}}}={{{{1}}}} ' \
                  .format(x, os.environ[x]) for x in [$ex_vars]])"`
            exec $SUDO PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
                     MANPATH=$MANPATH XDG_DATA_DIRS=$XDG_DATA_DIRS \
                     PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
                     "$py_cmd_path" -c \
                   'import base64;
                   exec(base64.b64decode("""{{SSH_PY_CODE}}""").decode("utf-8"))'
        else
            exec $SUDO "$py_cmd_path" -c \
                   'import base64;
                   exec(base64.b64decode("""{{SSH_PY_CODE}}""").decode("utf-8"))'
        fi
        exit 0
    else
        continue
    fi
done
echo "ERROR: Unable to locate appropriate python command" >&2
exit $EX_PYTHON_INVALID
EOFtEX_THIN_PYTHON_INVALIDussh_py_shim.pyuctSSHcB@s�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ed	�Ze
d
�Ze
d�Ze
dd�Zd
�Zdd�ZRS(u(
    Create an SSH execution system
    u#__needs_updatecC@sittj6|_tjj|dd�}tjj|�rytryt	j
jjd|d|dd|dt
�|_n	d|_||_|jdr�t|jd<nt	j
jjd	�s�t	jjd
ddd
��nt�|jd<|jdr|jdnd|_|j�t	jj|j|jjdd��|_|jj|jd|j�|_|jsz|j�nd|jkr|jdjd�r�tjjtjjd��r�tjjd�}q9|jdjdtjj|jddd	d��}n.|jjdtjj|jdd	d��}|dkr�tjj|�s�yt	jjjj |�Wq�t!k
r�t	jj"d��q�Xq�ni|jjdt	j#j$d�d6|jjdt	j#j$d�d6|jjd t	j#j$d �d!6|d"6|jjd#t	j#j$d#�d$6|jjd%t	j#j$d%�|jjd&t	j#j$d&�d&6|jjd't	j#j$d'�d(6|jjd)t	j#j$d)�d*6|jjd+t	j#j$d+�d,6|jjd-�d.6|jjd/�d/6|_%|jjd0�rDtjjd1d2j&t'j(�j)d3 ��|j%d4<d5|jd<nt	j*j+|�|_,t	j-j.|ji�|_.t	j/j0|j�|_1t	j
j2j3|jd6d7|jjd8�d9|jdd:|jd;d<|jd=d>|jjd?��|_2t4|j1�|_5dS(@Nusock_dirumaster_event_pull.ipcumasteru	transporttoptstlistenu
regen_thinussh_wipeusshtcodei����tmsguRNo ssh binary found in path -- ssh must be installed for salt-ssh to run. Exiting.u_ssh_versionuselected_target_optionugloburosteruflatutgtu__master_opts__ussh_use_home_keyu
~/.ssh/id_rsaussh_privupki_dirusalt-ssh.rsauagent-forwardingu'salt-ssh could not be run because it could not generate keys.

You can probably resolve this by executing this script with increased permissions via sudo or by running as root.
You could also use the '-c' option to supply a configuration directory that you have permissions to read and write to.ussh_useruuserussh_portuportu
ssh_passwdupasswduprivussh_priv_passwdupriv_passwdussh_timeoututimeoutussh_sudousudou
ssh_sudo_useru	sudo_userussh_identities_onlyuidentities_onlyussh_remote_port_forwardsuremote_port_forwardsussh_optionsu
rand_thin_diru/var/tmpu.{0}iuthin_diruTrueucachedirt
extra_modsuthin_extra_modst	overwritetpython2_binupython2_bintpython3_binupython3_bintextended_cfgussh_ext_alternatives(6tTrueR
tROSTER_UPDATE_FLAGt_SSH__parsed_rosterstostpathtjointexistsRtsalttutilsteventt	get_eventtFalsetNoneRtwhicht
exceptionstSaltSystemExittssh_versionttgt_typet_expand_targettrostertRostertgetttargetst_update_targetstisfilet
expandusertclienttsshtshelltgen_keytOSErrortSaltClientErrortconfigtDEFAULT_MASTER_OPTStdefaultstformattuuidtuuid4thextpayloadtSerialtserialtloadert	returnerst
fileclienttFSClienttfsclienttthintgen_thintmod_datatmods(tselfRt	pull_socktpriv((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt__init__�s�
		
#
*	
	

			

											
		&


cC@swtjj|j�}||jkrst|tjj|ji�|jd|jd|jd�}||j|<n|S(uM
        Read roster filename as a key to the data.
        :return:
        urendererurenderer_blacklisturenderer_whitelist(RR'tget_roster_fileRRRR>trender(RGtroster_filetroster_data((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt_get_rosterJscC@sB|jd}t|t�r dS|jdjd�d}d|komtjjj|�omtjjj|�}|r>tjjj	|�}|dkr�dS|j�x�|jD]�}|j|}t|t
�s�xc|D]X}|||jd�gkr�||jdkr||jd<nt|j|j<dSq�Wq�q�WndS(us
        Figures out if the target is a reachable host without wildcards, expands if any.
        :return:
        utgtNu@i����u*uhost(Rt
isinstancetlisttsplitRRtnetworktis_reachable_hosttis_ipt
ip_to_hostR RORtboolR)RR(RGttargetthostnametneeds_expansiontroster_filenameRNthost_id((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR&Ws*



cC@s
|j�}tj|tj�r�|j|jr	tjjj	|d��z}|j
djdtj
�dtjj�j�d|jjdd�d|jjd	d�d
|jjdd���WdQXtjd
j|jjdd�|��q	ntjdj|��dS(u]
        Update default flat roster with the passed in information.
        :return:
        uauw# Automatically added by "{s_user}" at {s_time}
{hostname}:
    host: {hostname}
    user: {user}
    passwd: {passwd}
ts_userts_timeRYutgtutuserussh_usertpasswdu
ssh_passwdNu-The host {0} has been added to the roster {1}u*Unable to update roster {0}: access denied(RORtaccesstW_OKRRRRtfilestfopentwriteR7tgetpasstgetusertdatetimetutcnowt	isoformatRR)tlogtinfoterror(RGRMt	roster_fp((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt_update_rosteruscC@s�|jjdd�}d|kr<|jdd�\}}n|jjd�}|dkrcd}ntjjj|�r�tjjj|�}||jd<i|jjdd�d6|d	6|d
6|j|<|jjd�r�|j	�q�ndS(
uj
        Uptade targets in case hostname was directly passed without the roster.
        :return:
        utgtuu@iussh_useru*u
ssh_passwdupasswduhostuuserussh_update_rosterN(
RR)RRRRRSRTRVR*Ro(RGRYR_((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR+�s	
c	C@s�d|jkrX|jdjd�rXtjjtjjd��rXtjjd�}n.|jjdtjj|jddd��}dj|�}tj	j
j|d	��$}d
j|j�j
�d�SWdQXdS(
u>
        Return the key string for the SSH public key
        u__master_opts__ussh_use_home_keyu
~/.ssh/id_rsaussh_privupki_dirusshusalt-ssh.rsau{0}.puburu{0} rsa root@masteriN(RR)RRR,R-RR7RRRcRdtreadRR(RGRItpubtfp_((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt
get_pubkey�s		
cC@st||t�s&|jjd�rl|j|}|jdt�sR|jdrh|j||t�n|S||jdd�jd�r|j|}tdj	|��t
d�}|jd
�r�|Stjdj	|d|��|d<|j||t
�S|S(u>
        Deploy the SSH key if the minions don't auth
        ussh_key_deployupasswdu
ssh_passwdustderruuPermission deniedu\Permission denied for host {0}, do you want to deploy the salt-ssh key? (password required):u[Y/n] unuNuPassword for {0}@{1}: uuser(unuN(RPtdictRR)R*Rt_key_deploy_runtcounttprintR7Rt
startswithRfR(RGthosttretRXtdeploy((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt
key_deploy�s &

	
c
C@s�d|jdd�|j�g}t|j||d|jd|jd|j|�}tjj	j
d�r�|jj�\}}}n|j
�\}}}|r[|jd�t|j|jd	|d|jd|jd|j|�}|j�\}}}y0tjjj|�}	i|	jd
|	�|6SWq[tk
rW|rLi||6Sid|6SXntjjj|kr{i||6Si||6S(u)
        The ssh-copy-id routine
        ussh.set_auth_keyuuserurootRFRBRCussh-copy-idupasswduargvulocalu
Bad Return(R)RstSingleRRFRBRCRRRR!R0tcopy_idtruntpopt	cmd_blocktjsont	find_jsont	ExceptionR6t	exitcodestEX_OK(
RGRyRXtre_runtargvtsingletstdouttstderrtretcodetdata((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyRu�sF			

			
c
C@stj|�}t||d|d|jd|jd|jd||�}i|jd6}|j�\}}	}
ygtj	j
j|�}t|�dkr�d|kr�|d|d	<ni|d
6|	d6|
d6|d	<Wn0t
k
ri|d
6|	d6|
d6|d	<nX|j|�d
S(uH
        Run the routine in a "Thread", put a dict on the queue
        uargvRFRBRCtmineuidiulocaluretustdoutustderruretcodeN(tcopytdeepcopyR}RFRBRCtidRRRR�R�tlenR�tput(RGtqueRRyRXR�R�RzR�R�R�R�((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pythandle_routine�s4				
cc@stj�}i}|jj�}t�}t�}t}x�tr|js\tjd�Pnt	|�|j
jdd�kr�|r�yt|�}Wnt
k
r�t}q<nXx?|jD]4}	|	|j|kr�|j|	|j||	<q�q�Wd|j|kr||j|d<n|j|jd�r�tr�|j|�|j|�d}
tj|
�igd6dd6|
d	6d
d6dd
6|d6}i||6Vq<n||j
||j||f}td|jd|�}
|
j�i|
d6||<q<ni}yG|jt�}d|krJ|j|d�i|d|d6VnWntk
r^nXx|D]}||dj�sf||krJyTxMtr�|jt�}d|kr�|j|d�i|d|d6Vq�q�WWntk
r�nX||krJdj|�}i|d6|d6}tj|�i|d|d6VqJn||dj�|j|�qfqfWx*|D]"}||krw|j|�qwqwWt	|�t	|j�kr�Pnt	|�|j
jdd�ks�t	|j�t	|�kr<tjd�q<q<WdS(ue
        Spin up the needed threads or processes and execute the subsequent
        routines
        u$No matching targets found in roster.u
ssh_max_procsiuhostuwinrmuTPlease contact sales@saltstack.com for access to the enterprise saltwinshell module.ufun_argsujidureturniuretcodeuufunuidRXtargsuthreaduretu?Target '{0}' did not return any data, probably due to an error.g�������?N(tmultiprocessingtQueueR*t__iter__tsetRRRkRmR�RR)tnextt
StopIterationR6tHAS_WINSHELLtaddtdebugR RR�tstartR�tis_aliveR7RR�ttimetsleep(RGR�R�trunningttarget_itertreturnedtretstinitRytdefaulttlog_msgtno_retR�troutineRzRm((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt
handle_sshs�				
(






			


	
	



<cc@s/dj|jd�}|j|d|p;|jjdd��}|jd}|jjdt�rrd}|}n |r�|dnd	}|d
}i|d6|jd6|jdd6|jd
d
6|d6|d6}|jddkr|jdj|jd�||d|jj��n$|jdj|jd�||�x�|j	d|�D]�}t
tj|��}	|j
||	||	|�|jr"t
tj|��\}
}t|tj�r�i|d6}nd|kr�|
|d<n||d<|jj|tjjj|d|	gd��n|VqSWdS(uJ
        Execute and yield returns as they come in, do not print to the display

        mine
            The Single objects will use mine_functions defined in the roster,
            pillar, or master config (they will be checked in that order) and
            will modify the argv with the arguments from mine_functions
        u{0}.prep_jidumaster_job_cachet
passed_jidujiduargvu	raw_shellussh._rawiuiutgt_typeutgtuuserufunuargulocal_cacheu
{0}.save_loadtminionsR�ureturnuiduretujobN(R7RR?R)R RR%R*tkeysR�R�Rtiterkeyst	cache_jobRt	iteritemsRPt	text_typet
fire_eventRRttagify(RGR�tjidtfstrR�tfunR�tjob_loadRzRytid_R�((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pytrun_itersD	+
	


6$	

	
cC@sA|jdj|jd�i|d6|d6|d6|d6�dS(u+
        Cache the job information
        u{0}.returnerumaster_job_cacheujiduidureturnufunN(R?R7R(RGR�R�RzR�((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR��s$c
C@sZ|jjd�r�|j�i}xk|jD]`}|jd�rGq,ni||<x8|j|D])}|j||d}||||<q_Wq,Wtjj|d|j�tj	�ndj
|jd�}|j|d|p�|jjdd'��}|jd	}|jjd
t
�r(d}|}	n |r8|dnd
}|d}	i|d6|jd6|jdd6|jdd6|d6|	d6}
y�t|t�r�|jd�}n|jddkr�|jdj
|jd�||
d|jj��n$|jdj
|jd�||
�Wn:tk
rW}tj|�tjd|jd|�nX|jjd�r�dj
|�}t|�tdt|�d�td
�ni}
|jjdd�}d}x=|j�D]/}ttj|��}t||t�r2||jdd�}|dkr8d}q8nd}|j|||||�|j ||�}t||t�r�||jd�p�d
jd �r�||d||<nt||t�s�i|||6}n[d!||kr�|}nB||jd"|jjdd��}i||jd!i�|6}|jjd#�rR|
j!|�ntjj|||j�|j"r�ttj#|��\}}t|tj$�r�i|d!6}nd$|kr�||d$<n||d<|j"j%|tj&j"j'|d%|gd&��q�q�W|jjd#�r7tjj|
||j�n|rVtj	tj(j)j*�nd'S((uK
        Execute the overall routine, print results via outputters
        u
list_hostsu#uhostunestedu{0}.prep_jidumaster_job_cacheR�ujiduargvu	raw_shellussh._rawiuiutgt_typeutgtuuserufunuarguutf-8ulocal_cacheu
{0}.save_loadR�u(Could not save load with returner %s: %suverboseuExecuting job with jid {0}u-u
uoutputuretcodeustderrussh:ureturnuoutustaticuiduretujobN(+RR)RORRxRtoutputtdisplay_outputtsystexitR7R?R RR%RPtbytestdecodeR*R�R�Rkt	exceptionRmRwR�R�R�RR�RtR�R|tupdateRR�R�R�RR�R6R�tEX_AGGREGATE(RGR�RzRMR\RYR�R�R�R�R�texcRtsrett	outputtert
final_exitRythost_rettp_dataR�R�((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR�s�


+
	


6(


5	%	
	

		
N(t__name__t
__module__t__doc__RRJROR&RoR+RsR|RRuRR�R�R R�R�R(((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR
�s	|	
					-#`6		R}cB@s�eZdZddddddeedddededdedd�Zd�Zd�Zd�Zd�Z	ed�Z
d�Zd	�Zd
d�Z
ed�Zd
�Zd�Zd�ZRS(u*
    Hold onto a single ssh execution
    icK@s�||_|jd�|_|jdd�|_||_||_||_|jd�rft|_	nt
|jjd��|_	|jd�r�|d|_n�|jr�tj
|�|jd�|_nd|r�tjd|�}ntjdd�}|jd	tjtjtjjj��jd
 �|_|j|jd<||_i|jd6|jd6|_t|tj�r�|g|_n	||_|j�\|_ |_!|_"||_#t|
t$�r�|
ni|_%i|d
6|d6|d6|d6|d6|	d6|
d6|d6|d6|j%d6|d6|d6|d6|d6|d6}it&d6dd6|_'|j'j(|jdi��|dk	r�|j'j(|�n|j'j(it)j*j+|jd �d!6|j#d"6d#d$6d%d&6�tj,j-j.|j'�|_/||_0|j0j(|�tj1j2|�|_3tj4j5|d|j�|_6tj7j8j9j:||�|_9|jr�|j9j;d'�\}}}|j<�|_=n|r�|ntjj>j?|d(�|_>dS()Numine_functionsu	cmd_umaskudisable_wipeussh_wipeuthin_dirussh_python_envu%%USER%%urootu%%FQDNUUID%%iumaster_optsu
fileclientuhostuuseruportupasswduprivupriv_passwdutimeoutusudouttyumodsuidentities_onlyu	sudo_useruremote_port_forwardsuwinrmussh_optionsugrains_cacheu
salt-call.logulog_fileussh_minion_optsurunning_datauroot_diruidu/usock_diriufileserver_list_cache_timeu&powershell $ENV:PROCESSOR_ARCHITECTUREucachedir(@R�R)tmine_functionsR t	cmd_umasktwinrmRtttyRtwipeRWtthin_dirtsaltwinshelltset_winvarst
python_envtDEFAULT_THIN_DIRtreplaceR8tuuid3t
NAMESPACE_DNSRRRStget_fqhostnameR:RBtcontextRPRtstring_typesR�t_Single__arg_compsR�R�tkwargsR�RtRFRtminion_optsR�RRRtserializerstyamlt	serializet
minion_configRXR;R<R=R>tssh_wrappertwfuncsR.R/R0t	gen_shelltexec_cmdtstriptarchRCt	thin_path(RGRR�R�RyR_tportR`RItpriv_passwdttimeouttsudoR�RFRBRCR�R�tidentities_onlyt	sudo_usertremote_port_forwardsR�tssh_optionsR�R�R�R�t_((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyRJ7s�					
"	
		




		cC@st|jr|jdnd}tjjj|jddtd|jjdg��}|d}|d}|||fS(u;
        Return the function name and the arg list
        iuit	conditiontno_parseuno_parse(R�RRR�tparse_inputRRR)(RGR�tparsedR�tkws((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt__arg_comps�s


cC@sI|jr
|Sdjg|D](}tjd|�r<d|n|^q�S(u
        Properly escape argument to protect special characters from shell
        interpretation.  This avoids having to do tricky argument quoting.

        Effectively just escape all characters in the argument that are not
        alphanumeric!
        uu\Wu\(R�Rtretmatch(RGtargtchar((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt_escape_arg�s	cC@s6|jj|jtjj|jd��|j�tS(u"
        Deploy salt-thin
        u
salt-thin.tgz(	R0tsendRCRRRR�t
deploy_extR(RG((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR{�s
	
cC@sE|jjd�rA|jj|jdtjj|jd��ntS(u-
        Deploy the ext_mods tarball
        ufileusalt-ext_mods.tgz(	RFR)R0RRRRR�R(RG((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR�s
	
cC@s�d}}}|jjdt�rodjg|jD]}|j|�^q3�}|jj|�\}}}nE|j	|j
ks�|jr�|j�\}}n|j
�\}}}|||fS(uC
        Execute the routine, the routine can be either:
        1. Execute a raw shell command
        2. Execute a wrapper func
        3. Execute a remote Salt command

        If a (re)deploy is needed, then retry the operation after a deploy
        attempt

        Returns tuple of (stdout, stderr, retcode)
        u	raw_shellu N(R RR)RRR�RR0R�R�R�R�t	run_wfuncR�(RGtdeploy_attemptedR�R�R�R�tcmd_str((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR�s.cC@s�t}d }tjj|jdd|j�}tjj|�sPtj|�ntjj|d�}t}tjj	|�s�t
}nDtj�tj|�j
d}||jjdd�kr�t
}n|jjd�r�t
}ni}d|jkr
|jd}n|st
}n|r�tjjjj|j|jd|jd	|j|j�}|d
�}	d|	kr�|	d}
tjjji|	d
6�}||
fS|jd|	d<|jd|	d<|jd|	d<|jd|	d<|jd|	d<|jd|	d<|jd|	d<d|jkr;|jd|	d<nd|jkr^|jd|	d<n|jd|	d<|j|	d<d}
x |D]}|||	d|<q�Wd|jkr�x1|jdD]}|jd||	d|<q�Wni}
|
j|	d�|
j|	�tjj|
|	d|	d|	jdd��}|j�}i|	d6|	dd6|d6}|r�tjjj |d�� }|j!|j"j|��Wd QXq�n|r�|r�tjjj |d!��}|j"j#|�}Wd QXn|jdi�}|jd�|d<x |D]}|||d|<qWd|jkrzx1|jdD]}|jd||d|<qTWn|jd�|d<tjjjj||jd|jd	|j|j�}tj$j%|||j�|_&|j&|_&|j'r�d }d }|j(}|j)r9|j(|j)kr9|j)|j(}n~|drz|j(|djd"i�krz|dd"|j(}n=|j(|jdjd"i�kr�|jdd"|j(}nt*|t+�r�|j,d#|�}|}nnt*|t-�rIxM|D]D}t*|t+�r�d#|kr�|d#}|j,|j.|��q�q�W|}n|}t*|t+�rsg|_/||_0q�t*|t-�r�||_/i|_0q�nyH|j'r�|||j/|j0�}n|j&|j(|j/|j0�}Wn�t1k
r(}d$j2|j(|�}t3j4|d%t5j6�d&}
nDt7k
rk}d'j2|j(|�}t3j4|d%t5j6�d&}
nXt*|t+�r�d
|kr�tjjji|d
d
6�}n#tjjjii|d(6d
6�}||
fS()uV
        Execute a wrapper function

        Returns tuple of (json_data, '')
        ucachediruminionsu
ssh_data.pi<u
cache_lifeu
refresh_cacheu
ssh_grainsRBR�u
test.opts_pkgu_erroruretcodeulocalu
file_rootsupillar_rootsu
ext_pillaruextension_modulesumodule_dirsu_ssh_versionumaster_optsu__master_opts__uknown_hosts_fileu_caller_cachediruidiugrainsusaltenvubaseuoptsupillaruw+bNurbumine_functionsu
mine_functionu(TypeError encountered executing {0}: {1}texc_info_on_logleveliu.An Exception occurred while executing {0}: {1}ureturn(8RR RRRRR�tisdirtmakedirsR,RR�tstattst_mtimeR)RR.R/twrappertFunctionWrapperRBR�RXRR�tdumpsR�R�tpillartPillartcompile_pillarRcRdReR=tloadR>R�R�R�R�R�RPRtR�RQtindexR�R�t	TypeErrorR7RkRmtloggingtDEBUGR�(RGt
data_cacheR�tcdirtdataptrefreshtpassed_timetconf_grainstpre_wrappertopts_pkgR�RztgraintpoptsRtpillar_dataRrRRt	mine_argst
mine_fun_datatmine_funtitemtresultR�((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR�s�"	 					




 
	



 				)"	
				#	
##cC@s�|jdrdnd}|jd}d|jkrE|jd}n
|jd}tjjj|d�\}}d}|jjd�s�d|jd<ntjjd	tjj|jjdd�kr�d
}ndj	d|j
d
td|jd|dddtj
jd|jjdd�d|jd|jd|jd|d|j�}tjd|�}tjrx|jd�}	n!tj|jd��jd�}	|js�tj	d|d|d|d|	d tjd!�}
nt j!|	�}
|
S("u,
        Prepare the command string
        usudouu	sudo_useru_caller_cachedirucachedirusha1u	log_leveluinfoudebugu1uf
OPTIONS.config = """
{config}
"""
OPTIONS.delimiter = '{delimeter}'
OPTIONS.saltdir = '{saltdir}'
OPTIONS.checksum = '{checksum}'
OPTIONS.hashfunc = '{hashfunc}'
OPTIONS.version = '{version}'
OPTIONS.ext_mods = '{ext_mods}'
OPTIONS.wipe = {wipe}
OPTIONS.tty = {tty}
OPTIONS.cmd_umask = {cmd_umask}
OPTIONS.code_checksum = {code_checksum}
ARGS = {arguments}
R4t	delimetertsaltdirtchecksumthashfunctversiontext_modsuversionR�R�R�t
code_checksumt	argumentsu#%%OPTSubase64uutf-8RtSUDOt	SUDO_USERtSSH_PY_CODEt
HOST_PY_MAJORi("RXRRRRCtthin_sumR)Rkt
LOG_LEVELSR7R�tRSTRR�R*t__version__RFR�R�R�R�tSSH_PY_SHIMR�RtPY2tencodetbase64tencodebytesR�R�tSSH_SH_SHIMR�tversion_infoR�tgen_shim(RGR�R�tcachedirtthin_code_digestR2R�targ_strtpy_codetpy_code_enctcmd((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt_cmd_str�sH

/						!		upycC@s�|jr$|jr$|jj|�Stjdddddt��#}|jtj	j
j|��WdQXdjt
jtjd��jd	�|�}|jr�tj||�}n|jj|j|d
t�ytj|j�Wntk
r�nX|dkr |jjdj|��}n9|jsG|jjd
j|��}ntj||�}|js~|jjdj|��n|jjdj|��|S(u�
        Run a shim command.

        If tty is enabled, we must scp the shim to the target system and
        execute it there
        tmodeuw+btprefixushim_tdeleteNu.{0}.{1}iuasciiRups1u"powershell {0}"u/bin/sh '$HOME/{0}'urm '$HOME/{0}'udel {0}(R�R�R0R�ttempfiletNamedTemporaryFileRReRRtstringutilstto_bytesR7tbinasciithexlifyRturandomR�R�tget_target_shim_fileRtnameRtremovetIOErrortcall_python(RGRt	extensiont
shim_tmp_filettarget_shim_fileRz((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pytshim_cmd�s2"		
		c	C@sWt|j�|_tjddjg|jD]}tj|�^q+��|j�}|j|�\}}}tj	d|j
d|�tj	d|j
d|�tjd|j
d|�|j|||�}|rq|dkr{tj
|�|j|�\}}}x5tjt|�r?tjt|d�dj�}qWx+tjt|�rwtjt|d�dj�}qCWqq|d	krX|j�|j|�\}}}tjt|�s�tjt|�r�d
j|�||fSx5tjt|�rtjt|d�dj�}q�WxNtjt|�rTtjt|d�dj�}q Wqqdj|�||fSnx5tjt|�r�tjt|d�dj�}qtWtjt|�r�x�tjt|�r�tjt|d�dj�}q�WnTtjd|d�d
j�}tjd||�d|krm|tjjjkrm|j�|j|�\}}}tjt|�s�tjt|�r�|js�tjd|||�|j�Stjt|�s�tjd|||�q�nx5tjt|�rtjt|d�dj�}q�W|jr2d}qJxtjt|�ritjt|d�dj�}q5Wn�d|krJ|j�|j|�\}}}tjt|�s�tjt|�r�dj|�||fSx5tjt|�rtjt|d�dj�}q�Wx8tjt|�rFtjt|d�dj�}qWn|||fS(uO
        Prepare the pre-check command to send to the subsystem

        1. execute SHIM + command
        2. check if SHIM returns a master request or if it completed
        3. handle any master request
        4. re-execute SHIM + command
        5. split SHIM results from command results
        6. return command results
        u3Performing shimmed, blocking command as follows:
%su uSTDOUT %s
%suhostuSTDERR %s
%suRETCODE %s: %su.Python environment not found on Windows systemiuUndefined SHIM stateu3ERROR: Failure deploying thin, undefined state: {0}u
ERROR: {0}u\r?\niu SHIM retcode(%s) and command: %sudeployuJERROR: Failure deploying thin, retrying:
STDOUT:
%s
STDERR:
%s
RETCODE: %suuext_modsu&ERROR: Failure deploying ext_mods: {0}(t
_convert_argsR�RkR�RRR�RDRWttraceRXtcategorize_shim_errorsR�t
deploy_pythonR�tsearchtRSTR_RERRR�R{R7RR6R�tEX_THIN_DEPLOYR�RmR�R(	RGtis_retryR�RR�R�R�Rmtshim_command((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR�s�/
#&
&#&#&!
&	

#		&
&#&c
C@s�tjjj|�}tjjj|�}tjt|�rP|tdkrPdStjt|�rfdS|j	d�rydSd}d�}dtj
jjfd|�ftj
jj
fd	d
ftj
jjfddftj
jjfd
d|fdd d|j|�fd!d|j|�fd"d|j|�ftj
jjfdd|fd$d&g}x<|D]4}	||	dks�tj|	d|�rc|	dSqcWdS('Nu
uUndefined SHIM stateuPermission denieduFPermissions problem, target user may need to be root or use sudo:
 {0}cS@s�iidd6dd6d6idd6d6d	d6}tjd \}}|j|i�j|�p�|j|i�jd�p�|d}d
|S(NuvInstall Python 2.7 / Python 3 Salt dependencies on the Salt SSH master 
to interact with Python 2.7 / Python 3 targetsiuvInstall Python 2.6 / Python 3 Salt dependencies on the Salt SSH master 
to interact with Python 2.6 / Python 3 targetsiiu�- Install Python 2.6/2.7 Salt dependencies on the Salt SSH 
  master to interact with Python 2.6/2.7 targets
- Install Python 3 on the target machine(s)udefaultiubMatching major/minor Python release (>=2.6) needed both on the Salt SSH 
master and target machineu0Python version error. Recommendation(s) follow:
(R�R<R)(tmessagestmajortminorthelp_msg((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt_version_mismatch_error�s

u5sudo: no tty present and no askpass program specifiedu+sudo expected a password, NOPASSWD requireduPython interpreter is too olduchecksum mismatchedu$The salt thin transfer was corruptedu
scp not foundu/No scp binary. openssh-clients package requiredu*salt path .* exists but is not a directoryu5A necessary path for salt thin unexpectedly exists:
 u,sudo: sorry, you must have a tty to run sudou"sudo is configured with requirettyuFailed to open log fileuPermission denied:.*/saltu&Failed to create directory path.*/saltuexists but is notu?An internal error occurred with the shim, please investigate:
 u)The system cannot find the path specifiedu.Python environment not found on Windows systemuis not recognizediii(((u5sudo: no tty present and no askpass program specifiedu+sudo expected a password, NOPASSWD required(((u,sudo: sorry, you must have a tty to run sudou"sudo is configured with requiretty((((((u)The system cannot find the path specifiedu.Python environment not found on Windows system(((uis not recognizedu.Python environment not found on Windows system(RRRJt
to_unicodeR�R\R]R4R RxR6R�R	tEX_THIN_CHECKSUMtEX_SCP_NOT_FOUNDtEX_CANTCREATR7tEX_SOFTWARE(
RGtstdout_byteststderr_bytesR�R�R�tperm_error_fmtReterrorsRm((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyRZmsd"		

	
&cC@sdS(u(
        Stub out check_refresh
        N((RGR�Rz((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt
check_refresh�scC@sdS(u;
        Module refresh is not needed, stub it out
        N((RG((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pytmodule_refresh�sN(R�R�R�R RRJR�RR{RRRRDRWR�RZRoRp(((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR}/s>V	
				�	=0h	p	cC@s�i}x�|D]�}d}g}xl|D]d}|dkrE||}n.|dkr^||}n|jd�rsq&n|jt||��q&W|r
||kr�g||<n||j|�q
q
W|S(u8
    Create a list of file ref objects to reconcile
    ubaseu__env__usaltenvu__(Rxtextendt	salt_refstappend(tchunkstrefstchunktsaltenvtcrefststate((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pytlowstate_file_refs�s"




cC@s�d}g}t|tj�r7|j|�r7|gSnt|t�r�xE|D]:}t|tj�rM|j|�r�|j|�q�qMqMWn|S(u5
    Pull salt file references out of the states
    usalt://(RPRR�RxRQRs(R�tprotoRztcomp((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyRrs

cC@s�dddddg}i}|j�}d}x%|D]}|j|�}x|D]�}i}dj|�}	x�t|�D]�}
|
j|	�rx|
jd�rtjjj	|
�}|j
||�}tjj
|�s�qxn||tjj|
�<tjjj|�}
||
7}qqxqxW|rP||kr@||j|�qM|||<qPqPWq4W|s_iStjr�tjjj|�}ntj|�j�}tjj|jddj|��}i|d
6|d6}tjj
|�r�|Stj|d�}tjj|jdd�}tjjj|d��}|j|�WdQX|j |d�xJ|D]B}x9||D]-}
|j |||
tjj||
��qhWqWW|j!�|S(u9
    Generate the module arguments for the shim data
    umodulesustatesugrainsu	renderersu	returnersuu_{0}u.pyu.sou.pyxucachediruext_mods.{0}.tgzuversionufileuw:gzuext_mods.veruw+Nuext_version(u.pyu.sou.pyx("tenvst	file_listR7tsortedRxtendswithRRturltcreatet
cache_fileRRR,tbasenamet	hashutilstget_hashR�RtPY3RJRKthashlibtsha1t	hexdigestRRttarfiletopenRcRdReR�tclose(RBt	sync_refsRzR}tver_basetenvRctreft	mods_datatpreftfn_tfulltmod_pathRvtvertext_tar_pathRFttfptverfileRr((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyREsb	

		



/
cC@s�tjddgdtjdtj�j�}y{|djd�djd�d}g}x@|D]8}y|jt|��Wqatk
r�t|�SXqaWt|�SWnt	k
r�dSXd
S(u:
    Returns the version of the installed ssh command
    usshu-VR�R�it,iR�iN(ii(
t
subprocesstPopentPIPEtcommunicateRRRstintt
ValueErrorttuplet
IndexError(Rzt
version_partstpartstpart((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyR$Os	$


cC@s�g}xy|D]q}t|t�rqxYt|j��D]5}|dkrMq5n|jdj|||��q5Wq
|j|�q
W|S(u�
    Take a list of args, and convert any dicts inside the list to keyword
    args in the form of `key=value`, ready to be passed to salt-ssh
    u	__kwarg__u{0}={1}(RPRtRQR�RsR7(R�t	convertedR�tkey((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyRXfs
$(aR�t
__future__RRRR9R�RfRR�R�R�R�RR�R�R�R8RHRLRhtsalt.outputRtsalt.client.ssh.shelltsalt.client.ssh.wrappertsalt.configtsalt.exceptionstsalt.defaults.exitcodestsalt.logtsalt.loadertsalt.miniontsalt.rostertsalt.serializers.yamlt
salt.statetsalt.utils.argstsalt.utils.atomicfiletsalt.utils.eventtsalt.utils.filestsalt.utils.hashutilstsalt.utils.jsontsalt.utils.networktsalt.utils.pathtsalt.utils.stringutilstsalt.utils.thintsalt.utils.urltsalt.utils.verifytsalt.utils.platformRtsalt.utils.processRt
salt.templateRtsalt.extRtsalt.ext.six.movesRR�RR�tImportErrorRtsalt.utils.zeromqRR�R4R]RR7R6R�R	RRtsR�R;Rtdirnamet__file__t	shim_fileRRRcRdtssh_py_shimRpR6t	getLoggerR�RktobjectR
R}RzRrRER$RX(((s</usr/lib/python2.7/site-packages/salt/client/ssh/__init__.pyt<module>s�


.5	"
!
��i���			=	

Zerion Mini Shell 1.0