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/cli/__pycache__/daemons.cpython-310.pyc
o

�N�gQ�
@s|dZddlZddlZddlZddlmmZddlmZm	Z	m
Z
ddlmZddl
mZddlmZejdded	d
d�ejdd
ed
d�ejdded
d�zddlZddlmZddlmZmZmZWneyZzejddkru�WYdZ[ndZ[wwe�e �Z!Gdd�d�Z"Gdd�dejj#j$e"�Z%Gdd�dejj#j&e"�Z'Gdd�dejj#j(e"�Z)Gdd�dejj#j*e"�Z+dS)z
Make me some salt!
�N)�SaltClientError�SaltSystemExit�get_error_message)�
migrations)�is_junos)�
HAS_PSUTIL�once�z^(salt|salt\.(.*))$T)�append�ignorez>With-statements now directly support multiple context managerszV^Module backports was already imported from (.*), but (.*) is being added to sys.path$)�
ip_bracket)�
check_user�
verify_env�
verify_socketzNo module named _msgpackc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�DaemonsMixinz1
    Uses the same functions for all daemons
    cCs2|jd��dvrt�d|jd|jj�dSdS)zq
        Verify and display a nag-messsage to the log if vulnerable hash-type is used.

        :return:
        Z	hash_type)�md5�sha1z_IMPORTANT: Do not use %s hashing algorithm! Please set "hash_type" to sha256 in Salt %s config!N)�config�lower�log�warning�	__class__�__name__��self�r�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/daemons.py�verify_hash_type=s��zDaemonsMixin.verify_hash_typecCst�d||jj�dS)zN
        Say daemon starting.

        :param action
        :return:
        z%s the Salt %sN�r�inforr)r�actionrrr�action_log_infoKszDaemonsMixin.action_log_infocC�t�d|jj�dS)z8
        Say daemon starting.

        :return:
        zThe Salt %s is starting upNrrrrr�start_log_infoT�zDaemonsMixin.start_log_infocCr")z=
        Say daemon shutting down.

        :return:
        zThe Salt %s is shut downNrrrrr�shutdown_log_info\r$zDaemonsMixin.shutdown_log_infocCs$t�d|jjt|��|�|�dS)z~
        Log environment failure for the daemon and exit with the error code.

        :param error:
        :return:
        z'Failed to create environment for %s: %sN)r�	exceptionrrr�shutdown�r�errorrrr�environment_failureds�z DaemonsMixin.environment_failureN)	r�
__module__�__qualname__�__doc__rr!r#r%r*rrrrr8s	rc�FeZdZdZ�fdd�Z�fdd�Z�fdd�Zd�fd
d�	Z�ZS)
�Masterz!
    Creates a master server
    cs.t|jd�r|jj�||�t��||�dS)N�process_manager)�hasattr�masterr0�_handle_signals�super�r�signumZsigframe�rrrr3zszMaster._handle_signalscs�t���z�|jdr�|jdtj�|jdd�tj�|jdd�tj�|jdd�tj�|jdd�tj�|jdd�|jdtj�|jdd	�tj�|jdd
�|jd|jd|jd
|jdg
}t||jd|jd|jd|jdd�t�|jd
�D]}t�tj�|jd
|��q�Wnt	y�}z|�
|�WYd}~nd}~ww|�d�t|jd|jd|jd�s�|�
dd�t|jd�|jd<t�|j�ddl}|j�|j�|_|��|��|jj��dS)z�
        Run the preparation sequence required to start a salt master server.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).prepare()
        r�pki_dirZminionsZminions_preZminions_deniedZminions_autosignZminions_rejected�cachedirZjobs�proc�sock_dirZ	token_dirZ
syndic_dirZsqlite_queue_dir�user�permissive_pki_access�root_dir�Z
permissiver>r8Nz
Setting upZ	interfaceZpublish_portZret_port�z#The ports are not available to bindr)r4�preparer�os�path�joinr�listdir�remove�OSErrorr*r!rr'rr�
migrate_pathsZsalt.masterr2r/�daemonize_if_required�set_pidfile�utils�processZnotify_systemd)r�v_dirsZsyndic_filer)�saltr7rrrA�sZ

�����
�zMaster.preparecs<t���t|jd�r|�d�|��|j��dSdS)z�
        Start the actual master.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).start()

        NOTE: Run any required code before calling `super()`.
        r<�Starting upN)r4�startr
rr!rr2rr7rrrP�s


�zMaster.startrNcs8|��d}|dur||}n|��}t��||�dS)zM
        If sub-classed, run any shutdown operations on this method.
        zThe salt master is shutdown. N)r%�stripr4r')r�exitcode�exitmsg�msgr7rrr'�s
zMaster.shutdown�rN�	rr+r,r-r3rArPr'�
__classcell__rrr7rr/ss=r/csVeZdZdZ�fdd�Z�fdd�Z�fdd�Zdd	�Zd
d�Zd�fdd�	Z	�Z
S)�Minionz 
    Create a minion server
    cs*t|jd�r|j�|�t��||�dS)N�stop)r1�minionrYr4r3r5r7rrr3�szMinion._handle_signalsc
s�t���zd|jdrh|j�d�}|r2d|vrtj�|�}tj�|�s1tj�tj�|jd�|�}ntj�tj�|jd�d�}|jd|jd|jd|jd	|g}t	||jd
|jd|jd|jdd
�Wnt
y�}z|�|�WYd}~nd}~wwt�
d|jd�t�|j�tr�|��r�ts�|��r�|�d�|�d�|j�d���}z&ddl}|��|��|j�d�dkr�|j�|j�|j�|j�|_WdSty�tjddd�|�d�YdSw)z�
        Run the preparation sequence required to start a salt minion.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).prepare()
        r�default_include�*�	conf_filezminion.dr8r9r;�extension_modulesr<r=r>r?NzSetting up the Salt Minion "%s"�id�'An instance is already running. Exiting��	transportr�master_type�funcz4An error occured while setting up the minion managerT)�exc_info)r4rAr�getrBrC�dirname�isabsrDrrGr*rrrrHrZclaim_process_responsibility�
check_runningr!r'r�salt.minionrIrJrZ�eval_master_funcZ
MinionManager�	Exceptionr))r�confdrMr)rbrNr7rrrA�sp

����������

��zMinion.preparec
sVt���	z|��WdSty*}z|jjrWYd}~qWYd}~dSd}~ww)z�
        Start the actual minion.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).start()

        NOTE: Run any required code before calling `super()`.
        TN)r4rP�_real_startr�options�daemon�r�excr7rrrP7s


�
���zMinion.startc
Cs�z#t|jd�r|�d�|��|j��|jjr!td��WdSWdStt	fy^}z-|�d�t
|t�rAt�d�|�
�nt�|�|�
|j�WYd}~dSWYd}~dSd}~ww)Nr<rOz"Minion could not connect to Master�Stopping�Exiting on Ctrl-c)r
rr!rrZ�tune_in�restartr�KeyboardInterruptr�
isinstancerrr'r)�coder(rrrrnKs&

�




���zMinion._real_startc
Cs�z!|��t|jd�rtjtjj|jjd<|j�	�WdSWdSt
tfy\}z-|�d�t
|t
�r?t�d�|��nt�|�|�|j�WYd}~dSWYd}~dSd}~ww)a�
        Start the actual minion as a caller minion.

        cleanup_protecteds is list of yard host addresses that should not be
        cleaned up this is to fix race condition when salt-caller minion starts up

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).start()

        NOTE: Run any required code before calling `super()`.
        r<Z__rolersrtN)rAr
r�kindsZAPPL_KIND_NAMESZ	applKindsZcallerrZ�optsZcall_inrwrr!rxrrr'r)ry)rZcleanup_protectedsrrrrr�call\s$
��




���zMinion.callrNcsP|�d�t|d�rt|jd�r|j��t��|d�|jj|p!d��	��dS)�}
        If sub-classed, run any shutdown operations on this method.

        :param exitcode
        :param exitmsg
        �
Shutting downrZ�destroy�The Salt {} is shutdown. {}r	N)
r!r1rZrr4r'�formatrrrQ�rrRrSr7rrr'ys

��zMinion.shutdownrU)rr+r,r-r3rArPrnr|r'rWrrr7rrX�sOrXcr.)
�ProxyMinionz&
    Create a proxy minion server
    cs|j�|�t��||�dS)N)rZrYr4r3r5r7rrr3�szProxyMinion._handle_signalsc
s�t���t�s|jjs|�d�zd|jdrt|j�d�}|r>d|vr)tj	�
|�}tj	�|�s=tj	�tj	�
|jd�|�}ntj	�tj	�
|jd�d�}|jd|jd|jd	|jd
|g}t
||jd|jd|jd
|jdd�Wnty�}z|�|�WYd}~nd}~ww|�d�|jd��t�|j�|��r�|�d�|�d�ddl}|��|��|j�d�dkr�|j�|j�|j�|j�|_dS)z�
        Run the preparation sequence required to start a salt proxy minion.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).prepare()
        zsalt-proxy requires --proxyidrr[r\r]zproxy.dr8r9r;r^r<r=r>r?N�Setting up "{}"r_r`rarrcrd)r4rAr�valuesZproxyidr)rrfrBrCrgrhrDrrGr*r!r�rrHrir'rjrIrJrZrkZProxyMinionManager)rrmrMr)rNr7rrrA�s^


��������

zProxyMinion.preparec
s�t���z#t|jd�r#|�d�|��|j��|jjr&t	d��WdSWdSt
tfyc}z-|�d�t|t
�rFt
�d�|��nt
�|�|�|j�WYd}~dSWYd}~dSd}~ww)z�
        Start the actual proxy minion.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).start()

        NOTE: Run any required code before calling `super()`.
        r<zThe Proxy Minion is starting upz(Proxy Minion could not connect to MasterzProxy Minion StoppingrtN)r4rPr
rr!rrZrurvrrwrrxrrr'r)ryrqr7rrrP�s(



�




���zProxyMinion.startrNcspt|d�r d|jjvr |jjdjd}|jjd||jj�|�d�t��|d�|jj	|p1d��
��dS)r}rZZproxymodulez	.shutdownr~r�r	N)r1rZr{Zloaded_base_namer!r4r'r�rrrQ)rrRrSZproxy_fnr7rrr'	s
��zProxyMinion.shutdownrUrVrrr7rr��sRr�cs:eZdZdZ�fdd�Z�fdd�Zd
�fdd	�	Z�ZS)�Syndicz 
    Create a syndic server
    c
s�t���z(|jdr,t|jd|jd|jdg|jd|jd|jd|jdd�WntyD}z|�|�WYd	}~nd	}~ww|�d
�|jd��dd	l}|�	�|j
�|j�|_|�
�d	S)
z�
        Run the preparation sequence required to start a salt syndic minion.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).prepare()
        rr8r;r^r<r=r>r?Nr�r_r)r4rArrrGr*r!r�rjrIrZZ
SyndicManager�syndicrJ)rr)rNr7rrrA's.

�����zSyndic.preparecsft���t|jd�r1|�d�|��z|j��WdSty0|�d�|�	�YdSwdS)z�
        Start the actual syndic.

        If sub-classed, don't **ever** forget to run:

            super(YourSubClass, self).start()

        NOTE: Run any required code before calling `super()`.
        r<rOrsN)
r4rPr
rr!rr�rurwr'rr7rrrPIs



��zSyndic.startrNcs0|�d�t��|d�|jj|pd����dS)r}r~r�r	N)r!r4r'r�rrrQr�r7rrr']s
��zSyndic.shutdownrU)rr+r,r-rArPr'rWrrr7rr� s
"r�),r-�loggingrB�warningsZsalt.utils.kindsrKrzZsalt.exceptionsrrrZ
salt.utilsrZsalt.utils.platformrZsalt.utils.processr�filterwarnings�DeprecationWarning�UserWarningZsalt.utils.parsersrNZsalt.utils.networkrZsalt.utils.verifyr
rr�ImportErrorrr�args�	getLoggerrrr�parsersZMasterOptionParserr/ZMinionOptionParserrXZProxyMinionOptionParserr�ZSyndicOptionParserr�rrrr�<module>sl�	�����

;
�
g
�
6
�

�