HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/__pycache__/scripts.cpython-310.pyc
o

�N�gAH�@sBdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
ZddlmZmZmZe�e�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd �Z#d!d"�Z$d#d$�Z%d%d&�Z&d'd(�Z'd)d*�Z(d+d,�Z)d-d.�Z*d/d0�Z+d1d2�Z,dS)3zI
This module contains the function calls to execute command line scripts
�N)�randint)�SaltClientError�SaltReqTimeoutError�SaltSystemExitc	Cs�z|jj}Wn
ttfyd}Ynw|tjkr6d}z|jjd}|d�|�7}Wn
ttfy5Ynwd}|dur@|r@d}|rJt	|t
jdd�|rizt�
�}t�|�Wn	ty`Ynwt
�tjjj�t
�tjjj�dS)NFz
Exiting gracefully on Ctrl-c�jidz�
This job's jid is: {0}
The minions may not have all finished running and any remaining minions will return upon completion. To look up the return data for this job later, run the following command:

salt-run jobs.lookup_jid {0}z"
Exiting with hard crash on Ctrl-cT��file�flush)�options�
hard_crash�AttributeError�KeyError�signal�SIGINTZlocal_clientZpub_data�format�print�sys�stderr�	traceback�
format_exc�log�error�exit�salt�defaults�	exitcodes�
EX_GENERIC�EX_OK)�client�signum�sigframeZ	hardcrashZexit_msgr�trace�r"�@/opt/saltstack/salt/lib/python3.10/site-packages/salt/scripts.py�_handle_signalss<�
���r$cCs^t�tj�tjtjfvrt�tjt�t|��t�tj�tjur-t�tjt�t|��dSdS�N)	r�	getsignalr�SIG_DFL�default_int_handler�	functools�partialr$�SIGTERM)rr"r"r#�_install_signal_handlers>s
�r,cCs8ddl}tdkrtjttjd<|jj��}|��dS)z 
    Start the salt master.
    rN�__main__)�salt.cli.daemons�__name__r�modules�cli�daemonsZMaster�start)rZmasterr"r"r#�salt_masterIs
r4c
srddl�t���jj_ddl�ddl�dd�}t�	����fdd�}z�z+�j
j��s8tj
|t��fd�}|���jj��}t�tjt�||��|��WnQtttfy�}zB�jdd	�tjd
dd�t�d�d
}|dur}t|d�r}|j�dd
�}t d|�}t�!d|�t"�#|�t$�%�j&j'j(�WYd}~nd}~wwW�jdd	�dSW�jdd	�dS�jdd	�w)z 
    Start a minion process
    rNcSs|j��dSr%)�minion�reload)�manager�sig�framer"r"r#�
handle_hupjsz"minion_process.<locals>.handle_hupc
s��jdd�rL���t�d�zt��dkr"�jj��s"t�	|d�Wn t
yC}zt�d|�t�
�jjj�WYd}~nd}~ww�jdd�sdSdS)z�
        Have the minion suicide if the parent process is gone

        NOTE: small race issue where the parent PID could be replace
        with another process with same PID!
        F��blocking�rz(Minion process encountered exception: %sN)�acquire�release�time�sleep�os�getuid�utils�platform�
is_windows�kill�OSErrorrr�_exitrrr)�
parent_pid�exc��lockrr"r#�suicide_when_without_parentos
����z3minion_process.<locals>.suicide_when_without_parent��target�argsTr;z4Fatal functionality error caught by minion handler:
��exc_infoz** Restarting minion **�<�config�random_reauth_delay�zwaiting random_reauth_delay %ss))Z
salt._loggingrB�getpidZ_loggingZin_mainprocessZ__pid__r.�salt.utils.platform�	threading�RLockrDrErF�Thread�getppidr3r1r2�Minionr�SIGHUPr)r*rrrr>r�warning�hasattrrU�getr�infor@rArrrr�SALT_KEEPALIVE)r:rN�threadr5rK�delayr"rLr#�minion_processYsF
��


����rgc
Cs�ddl}ddl}ddl}ddl}|jj��|jj��ddl	}ddl
}tdkr0tj
ttj
d<dtjvr;tj�d�|jj��rM|jj��}|��dSdtjvrdtj�d�|jj��}|��dSdd�}|�|j�}|�|j�}	z1|jtd	d
�}|��|�|jt�||j��|�|jt�||j��|�|jt�||j��Wnt y�|jj��}|��YdSw|�!�|�|j|�|�|j|�|j"|j#j$j%ks�t�&|j"�t'�(dt)dd
��t*�+�}|j,D]}	|�-|	�q�t*�.�qu)zR
    Start the salt minion in a subprocess.
    Auto restart minion on error.
    rNr-��--disable-keepalivecSst�||�dS)zy
        Escalate the signal received to the multiprocessing process that
        is actually running the minion
        N)rBrG)�pidrr r"r"r#�escalate_signal_to_process�sz/salt_minion.<locals>.escalate_signal_to_processTZMinionKeepAlive)rP�name�rW�
)/rZsalt.utils.debugrY�salt.utils.processrD�debugZenable_sigusr1_handler�process�notify_systemd�multiprocessingr.r/rr0�path�removerErFr1r2r^r3�argvr&rr+�Processrgr)r*rjr_�	Exception�join�exitcoderrrdrr@rAr�logging�	getLogger�handlers�
removeHandler�basicConfig)
rrrsr5rkZprev_sigint_handlerZprev_sigterm_handlerrq�rlogger�handlerr"r"r#�salt_minion�st

�����
�r�c
s|ddl}ddl}t����fdd�}zlz)|jj��s(tj|t�	�fd�}|�
�d}d}|jjj
}|jj��}|�
�Wn:ttttfy`}ztjddd	�d}|jjj}WYd}~nd}~wtyv}zd}|j}WYd}~nd}~wwW�jdd
�n�jdd
�w|dur�t�d�d}|dur�t|d
�r�|j�dd�}td|�}	t� d|	�|�!|	�n|�!d�t"�#|�dS)z&
    Start a proxy minion process
    rNcs`�jdd�r.���t�d�zt�|d�Wnty%t�d�Ynw�jdd�sdSdS)z�
        Have the minion suicide if the parent process is gone

        NOTE: there is a small race issue where the parent PID could be replace
        with another process with the same PID!
        Fr;r=ri�N)r>r?r@rArBrGrHrI)rJ�rMr"r#rN
s
��z9proxy_minion_process.<locals>.suicide_when_without_parentrOFzProxy Minion failed to start: TrRr;z** Restarting proxy minion **rTrUrVrWz*Sleeping random_reauth_delay of %s seconds)$r.rYrZr[rDrErFr\rBr]r3rrrr1r2�ProxyMinionrxrrrrrrd�
SystemExit�coder>r`rarUrbrrc�putrr)
�queuerrNreZrestart�proxyminion�statusrKrfZrandom_delayr"r�r#�proxy_minion_process�sV
�
�����



r�cCstddl}ddl}ddl}dtjvrtj�d�|jj��r)|j	j
��}|��dSdtj
vr@tj
�d�|j	j
��}|��dS	z|��}Wnty[|j	j
��}|��YdSw|jt|fdd�}|��z2|��z|jdd	�}Wnty�|jdkr�YWdSd
}Ynw|dkr�t�|j�t�|�Wn
ty�YdSwt��}|jD]}|�|�q�t��qA)z
    Start a proxy minion.
    rNrhriTr�)rPrQrlF)�blockrT)rsr.rYrrtrurDrErFr1r2r�r3rv�Queuerxrwr�ryrbrzrr@rA�KeyboardInterruptr{r|r}r~r)rsrr�r�rqZ
restart_delayr�r�r"r"r#�
salt_proxyIs\

��
��
�r�cCs`ddl}|jj��ddl}t��}z
|jj�	�}|�
�WdSty/t�|d�YdSw)z 
    Start the salt syndic.
    rN�)
rorDrqrrr.rBrXr1r2ZSyndicr3r�rG)rrjZsyndicr"r"r#�salt_syndic�s�r�c
Csfddl}z|jj��}t|�|��WdSty2}ztj�	d|�d��WYd}~dSd}~ww)z7
    Manage the authentication keys with salt-key.
    rNzError: �
)
Zsalt.cli.keyr1�keyZSaltKeyr,�runrxrr�write)rr�errr"r"r#�salt_key�s"��r�cCs(ddl}|jj��}t|�|��dS)�V
    Publish commands to the salt system from the command line on the
    master.
    rN)Zsalt.cli.cpr1ZcpZ	SaltCPClir,r��rrr"r"r#�salt_cp�sr�cC�>ddl}dtjvrtj�d�|jj��}t|�|��dS)zi
    Directly call a salt command in the modules, does not require a running
    salt minion to run.
    rNrh)	Z
salt.cli.callrrtrur1�callZSaltCallr,r�r�r"r"r#�	salt_call��
r�cCs>ddl}dtjvrtj�d�|jj��}t|�|��dS)z-
    Execute a salt convenience routine.
    rNrh)Zsalt.cli.runrrtrur1r�ZSaltRunr,r�r"r"r#�salt_run�s
r�cCs�ddl}dtjvrtj�d�z|jj��}t|�|��WdSt	y`}z4t
t|�tjdd�z|j
jr@t��}t�|�WnttfyLYnwt�|jjj�WYd}~dSd}~ww)z%
    Execute the salt-ssh system
    rNrhTr)Zsalt.cli.sshrrtrur1ZsshZSaltSSHr,r�rr�strrr
rrrrrrr
rrrr)rrr�r!r"r"r#�salt_ssh�s(

����r�c
Cs�z
ddl}ddl}Wn(ty2}zddl}t�d|�td�t�|j	j
j�WYd}~nd}~wwdtjvr>tj�
d�|jj��}t|�|��dS)z*
    The main function for salt-cloud
    rNzError importing salt cloud: %sz*salt-cloud is not available in this systemrh)Z
salt.cloudZsalt.cloud.cli�ImportError�salt.defaults.exitcodesrrrrrrr�EX_UNAVAILABLErtruZcloudr1Z	SaltCloudr,r�)r�err"r"r#�
salt_cloud�s��
r�cCs4ddl}|jj��ddl}|jj��}|��dS)z(
    The main function for salt-api
    rN)	rorDrqrrZsalt.cli.apir1ZapiZSaltAPIr3)rZsapir"r"r#�salt_api�s
r�cCr�)r�rNrh)	Z
salt.cli.saltrrtrur1rZSaltCMDr,r�r�r"r"r#�	salt_mainr�r�cCs ddl}|jj��}|��dS)z]
    The main function for spm, the Salt Package Manager

    .. versionadded:: 2015.8.0
    rN)Zsalt.cli.spmr1�spmZSPMr�)rr�r"r"r#�salt_spmsr�cCs$ddl}|jjj|||||d�dS)zb
    Quickstart for developing on the saltstack installation

    .. versionadded:: 2016.11.0
    rN)�	extensionrl�description�salt_dir�merge)Zsalt.utils.extendrD�extendr�)r�rlr�r�r�rr"r"r#�salt_extend"s
�r�cCs�g}ttjt�D]}|�d�r|�|dd��q	ttj�dkr8d}|D]	}|d|��7}q%t|�t�	d�tjd}||vrIdtjd<t
}nd	|��tjd<tj�d�ttjtd
|���}|�dS)z=
    Change the args and redirect to another salt script
    rr=Nrmz4Must pass in a salt command, available commands are:r�rWrzsalt-Zsalt_)
�dirrr0r/�
startswith�append�lenrvrrr��pop�getattr)ZavailZfun�msg�cmdZs_funr"r"r#�
salt_unity3s&
�



r�cCsF|dd�}d}|D]}d|vrd}q
d|vr!|s!|�d|���|S)NFz--targetT�installz	--target=)r�)rQrP�new_argsZtarget_in_args�argr"r"r#�	_pip_argsMs�r�cCs:|��}d|vr|�tj�|d��|d<|S||d<|S)N�
PYTHONPATH)�copyrB�pathsep)�env�extrasZnew_envr"r"r#�_pip_environmentXs�r�cCs4t�t��tjWd�S1swYdSr%)�
contextlib�suppressrr�RELENVr"r"r"r#�_get_onedir_env_pathas �r�cCs�t�}|durtdtjdd�t�tjjj�n
t	|dj
tj��}tt
j��|�}ttjdd�|�}tjddgttjdd�|�}tj|d	d	|d
�}t�|j�dS)z'
    Proxy to current python's pip
    Nzi'salt-pip' is only meant to be used from a Salt onedir. You probably want to use the system 'pip` binary.Trzextras-{}.{}rWz-mZpipF)�shell�checkr�)r�rrrrrrrrr�r�version_infor�rB�environr�r�rv�
executable�
subprocessr��
returncode)Zrelenv_pathr�r�rQZcommand�retr"r"r#�salt_piphs&���r�)-�__doc__r�r)r{rBrr�rrZr@r�randomrr�rZsalt.exceptionsrrrr|r/rr$r,r4rgr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r"r"r#�<module>sL
'EaJ<