HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/client/ssh/__pycache__/state.cpython-310.pyc
o

�N�g�%�@s�dZddlZddlZddlZddlZddlZddlmZddlZ	ddl
Z	ddlZ	ddlZ	ddl
Z	ddlZ	ddlZ	ddlZ	ddlZ	ddlZ	ddlZ	ddlZ	ddlZ	e�e�ZGdd�de	jj�ZGdd�de	jj�Zdd	d
�Zddd�Z	dd
d�Z dS)z
Create ssh executor system
�N)�closingcsPeZdZdZ				d
�fdd�	Zddd�Z�fdd�Zd	d
�Zdd�Z�Z	S)�SSHStatezR
    Create a State object which wraps the SSH functions for state operations
    Ncs"||_||_t�j|||d�dS)N)�initial_pillar)�wrapper�context�super�__init__)�self�opts�pillar_overriderrr��	__class__��I/opt/saltstack/salt/lib/python3.10/site-packages/salt/client/ssh/state.pyr"szSSHState.__init__cCsn|j|_tj�|j�|_tj�|j�|_tjj|j|jd�}tj�|j||j|j�|_tj�	|j|j�|_
dS)zD
        Load up the modules for remote compilation via ssh
        )�utilsN)rZ	functions�salt�loaderrr
ZserializersZminion_modsZstatesZrenderZrend)r	�data�proxyZlocals_rrr�load_modules.s�zSSHState.load_modulescsf|j}i}|�|�|�|�di��|d|d<|d|d<|�d�|d<||_t���}||_|S)z�
        The opts used during pillar rendering should contain the master
        opts in the root namespace. self.opts is the modified minion opts,
        containing the original master opts in __master_opts__.
        Z__master_opts__�id�saltenvZ	pillarenv)r
�update�getr�_gather_pillar)r	Z_optsZpopts�pillarrrrr;s

zSSHState._gather_pillarcC�dS)z(
        Stub out check_refresh
        Nr)r	r�retrrr�
check_refreshQ�zSSHState.check_refreshcCr)z;
        Module refresh is not needed, stub it out
        Nr�r	rrr�module_refreshWrzSSHState.module_refresh)NNNN)NN)
�__name__�
__module__�__qualname__�__doc__rrrrr!�
__classcell__rrrrrs�

rc@sXeZdZdZgZ					ddd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�SSHHighStatez5
    Used to compile the highstate on the master
    NcCsZ||_tjj�||�t|||||d�|_tj�|j�|_tj�	|j�|_	i|_
g|_dS)N)rr)�clientr�state�
BaseHighStaterrrZmatchersr
�topsZ_pydsl_all_declsZ_pydsl_render_stack)r	r
rrZfsclientrrrrrres	�
zSSHHighState.__init__cCstjjj�|�dS�N)rr)Z	HighState�stack�appendr rrr�push_active}szSSHHighState.push_activecCr)z'
        Stub out load_dynamic
        Nr)r	�matchesrrr�load_dynamic�rzSSHHighState.load_dynamiccCs�d|jvrt�d�iStjj�|j|jd�siSi}i}d|jvr(|jd}|jD]8}||j�di�vr7q+z|�	|j||j|d��Wq+t
yc}zt�d|||jd�WYd}~q+d}~ww|S)z.
        Evaluate master_tops locally
        rz.Received call for external nodes without an id�grainsZmaster_tops)r
r2z2Top function %s failed with error %s for minion %sN)r
�log�errorrrZverifyZvalid_idr+rr�	Exception)r	r2rZfun�excrrr�_master_tops�s0




���zSSHHighState._master_topscCs|jr
|j��dSdSr,)r(�destroyr rrrr8�s�zSSHHighState.destroycCs|Sr,rr rrr�	__enter__�szSSHHighState.__enter__cGs|��dSr,)r8)r	�_rrr�__exit__�szSSHHighState.__exit__)NNNNN)r"r#r$r%r-rr/r1r7r8r9r;rrrrr'^s
�r'�c
Cs�i}|D]:}t|t�sqd}g}|D]}|dkr||}n|�d�r#q|�t||��q||vr5g||<|r>||�|�q|rZ|�d�}|rZ|D]}|D]
}	||�|	g�qNqJ|S)z8
    Create a list of file ref objects to reconcile
    �baseZ__env__�__�,)�
isinstance�dict�
startswith�extend�	salt_refsr.�split)
�chunks�extrasZrefs�chunkrZcrefsr)Z
extra_refs�env�xrrr�lowstate_file_refs�s2


�
�rKcCszd}|durg}t|t�r|�|�r||vr|�|�t|t�r*|D]}t||�q"t|t�r;|D]	}t|||�q1|S)z5
    Pull salt file references out of the states
    zsalt://N)r@�strrBr.�listrDrA)rr�proto�comprrrrD�s



rDc Cs:t��}tjj��}tj�|d�}tj�|d�}	tj�|d�}
tjj	�
d�gtjj	�
d�gtjj	�
d�gtjj	�
d�gtjj	�
d�gtjj	�
d	�gtjj	�
d
�gg}tjj�|d��}tjj�
||�Wd�n1smwY|r�tjj�|	d��}tjj�
||�Wd�n1s�wY|r�tjj�|
d��}tjj�
||�Wd�n1s�wY|dur�d
}z
tj�d|��tj�}
Wnty�tj�dt|���tj�}
Ynw|D]�}tj�|
d|�}||�|�tj�||�}tj�|��st�|�||D]�}|D]�}tjj	�|�d�d�}tj�||�}z
|j|||
d�}Wnt�y9d
}Ynw|�r^tj�||�}tj�|�}tj�|��sVt�|�t�||��qz
|j|||
d�}Wnt�ytd
}Ynw|�r�|D]1}|t|�|��d��d�}tj�|||�}tj�|�}tj�|��s�t�|�t�||��qz�q�q�q
q�zt� �}Wnt�y�d}Ynwt�!|�t"t#�$|d���2}tjj�%|�D]"\}}}|D]}tj�||�}|�&|t|�d��tj���q�q�Wd�n	1�s	wY|�rt�!|�t�'|�|S)zf
    Generate the execution package from the saltenv file refs and a low state
    data structure
    z
lowstate.jsonzpillar.jsonzroster_grains.jsonZ_modulesZ_statesZ_grainsZ
_renderersZ
_returners�_outputZ_utilszw+Nr<zsalt-ssh�filesr�/)�cachedirzw:gz)(�tempfileZmkdtemprrrQZmkstemp�os�path�join�url�createZfopen�json�dump�rstrip�sep�AttributeErrorrLrC�isdir�makedirs�parse�lstripZ
cache_file�OSError�dirname�shutil�copyZ	cache_dir�lenZget_cachedir�strip�getcwd�chdirr�tarfile�openZos_walk�add�rmtree) Zfile_clientrFZ	file_refsrZid_Z
roster_grainsZgendirZ	trans_tarZlowfnZpillarfnZroster_grainsfnZ	sync_refsZfp_rSrZcache_dest_rootZenv_root�ref�nameZshortZ
cache_destrVZtgtZtgt_dirrQ�filename�fn�cwdZtfp�root�dirs�fullrrr�prep_trans_tar�s��	����
�
���
����
"���

rw)r<r,)NNN)!r%�loggingrUrerkrT�
contextlibrZsalt.client.sshrZsalt.client.ssh.shellZsalt.loaderZsalt.minionZsalt.rosterZ
salt.stateZsalt.utils.filesZsalt.utils.jsonZsalt.utils.pathZsalt.utils.stringutilsZsalt.utils.thinZsalt.utils.urlZsalt.utils.verify�	getLoggerr"r3r)�Staterr*r'rKrDrwrrrr�<module>s6
A
R
�