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

�N�gK5�@s�dZddlZddlZddlZddlZddlZddlm	m
Z
ddlZddlZddl
mZddlmZmZddlmZzddlZWn	eyJYnwe�e�Zdd�Zdd	�Zd
d�Zdd
d�Zddd�Zdd�Zdd�ZGdd�d�Z Gdd�d�Z!dS)z�
Many aspects of the salt payload need to be managed, from the return of
encrypted keys to general payload dynamics and packaging, these happen
in here
�N)�	_Constant)�SaltDeserializationError�SaltReqTimeoutError)�CaseInsensitiveDictcCstjj�|�S)z�
    This method for now just wraps msgpack.dumps, but it is here so that
    we can make the serialization a custom option in the future with ease.
    )�salt�utils�msgpack�dumps)�payload�r�@/opt/saltstack/salt/lib/python3.10/site-packages/salt/payload.py�packagesr
cCstjjj|dd�S)z
    Unpackages a payload
    T)�use_list)rrr�loads)Zpackage_rrr�	unpackage%srcKs2d|i}i}|D]}||||<q||d<t|�S)z�
    Pass in the required arguments for a payload, the enc type and the cmd,
    then a list of keyword args to generate the body of the load dict.
    �enc�load)r
)r�kwargsr
r�keyrrr�format_payload,srFc
Cs�zxzQdd�}t��d|d�}|durd|d<nd|d<z
tjjj|fi|��}WntyC|�dd�tjjj|fi|��}Ynw|durQ|sQtj	j
�|�}Wntyq}zt
�d|�t
�d	|�d
}t|�|�d}~wwWt��|St��w)aL
    Run the correct loads serialization format

    :param encoding: Useful for Python 3 support. If the msgpack data
                     was encoded using "use_bin_type=True", this will
                     differentiate between the 'bytes' type and the
                     'str' type by decoding contents with 'str' type
                     to what the encoding was set as. Recommended
                     encoding is 'utf-8' when using Python 3.
                     If the msgpack data was not encoded using
                     "use_bin_type=True", it will try to decode
                     all 'bytes' and 'str' data (the distinction has
                     been lost in this case) to what the encoding is
                     set as. In this case, it will fail if any of
                     the contents cannot be converted.
    cSsP|dkrtjj�|�}tj�|d�S|dkr&tjjj|dd�\}}t||�S|S)N�N�%Y%m%dT%H:%M:%S.%f�OF)�raw)	rr�stringutilsZ
to_unicode�datetime�strptimerrr)�code�data�name�valuerrr�ext_type_decoderLs
zloads.<locals>.ext_type_decoderT)rZext_hookNrFz�Could not deserialize msgpack message. This often happens when trying to read a file not in binary mode. To see message payload, enable debug logging and retry. Exception: %sz.Msgpack deserialization failure on message: %sz=Could not deserialize msgpack message. See log for more info.)�gc�disablerrrZunpackb�UnicodeDecodeError�poprZ	transport�frameZdecode_embedded_strs�	Exception�log�critical�debugr�enable)�msg�encodingrr!Zloads_kwargs�ret�excZexc_msgrrrr9s<	

���
���
�rc	sjdd�}ztjjj|||d�WSttjjjjfy4�fdd���|t��}tjjj|||d�YSw)a�
    Run the correct dumps serialization format

    :param use_bin_type: Useful for Python 3 support. Tells msgpack to
                         differentiate between 'str' and 'bytes' types
                         by encoding them differently.
                         Since this changes the wire protocol, this
                         option should not be used outside of IPC.
    cSs�t|t�r	t|�St|tjtjf�r"tjj�dtjj	�
|�d���St|t�r:tjj�dtjjj
|j|jfdd��St|tj�rDt|�St|tj�rNt|�St|ttjf�rZt|�St|t�rct|�St|tjj�rnt|�S|S)NrrrT��use_bin_type)�
isinstance�int�strr�daterrrZExtTyper�to_bytes�strftimerr	rr �immutabletypesZ
ImmutableDict�dictZ
ImmutableList�list�setZImmutableSet�tupler�collections�abc�MutableMapping)�objrrr�ext_type_encoder~s.
�
�
zdumps.<locals>.ext_type_encoder)�defaultr1cs�t|�}||vrt|tttf�rd�t|�jt|��S|�|�t|t�r;|�	��
�D]\}}�||�||<q+t|�St|ttf�rXt|�}t|�D]\}}�||�||<qJ|St|t�rh|t
dd�krht|�S|S)Nz<Recursion on {} with id={}>��@)�idr2r9r:r<�format�type�__name__�add�copy�items�	enumerater3�powr4)r@�contextZobjidrr �idx�entry��verylong_encoderrrrR�s$�

zdumps.<locals>.verylong_encoder)rrrZpackb�
OverflowError�
exceptionsZPackValueErrorr;)r,r1rArrQrr	ss"�
��r	cCs$|��}|��|rt|dd�SdS)z6
    Run the correct serialization to load a file
    zutf-8)r-N)�read�closer)�fn_rrrrr�s
�rcCs|�t|dd��|��dS)z?
    Serialize the correct data into the named file object
    Tr0N)�writer	rV)r,rWrrr�dump�srYc@s8eZdZdZdd�Zee�Zee�Zee�Zee	�Z	dS)�Serialzb
    Create a serialization object, this object manages all message
    serialization in Salt
    cOstjj�dd�dS)NZChlorinez�The `salt.payload.Serial` class has been deprecated, and is set to be removed in {version}. Please use `salt.payload.loads` and `salt.payload.dumps`.)rrZversionsZ
warn_until)�self�argsrrrr�__init__�s�zSerial.__init__N)
rH�
__module__�__qualname__�__doc__r]�staticmethodrr	rYrrrrrrZ�srZc@sZeZdZdZddd�Zedd	��Zd
d�Zdd
�Zddd�Z	ddd�Z
dd�Zdd�ZdS)�SREQzC
    Create a generic interface to wrap salt zeromq req calls.
    �rrNcCs0||_||_||_t��|_t��|_||_dS�N)	�master�id_�linger�zmqZContextrNZPoller�poller�opts)r[rerf�serialrgrjrrrr]�s


z
SREQ.__init__cCs�t|d�sW|j�tj�|_ttd�r|j�tjd�|��|j	�
d�r?ttd�r2|j�tjd�n
ttd�r?|j�tjd�|j
|j_
|jrP|j�tj|j�|j�|j	�|jS)	z+
        Lazily create the socket.
        �_socket�RECONNECT_IVL_MAXi�ztcp://[�IPV6��IPV4ONLYr)�hasattrrN�socketrhZREQrl�
setsockoptrm�_set_tcp_keepalivere�
startswithrnrprgrfZIDENTITY�connect�r[rrrrrs




zSREQ.socketcCs�ttd�rJ|jrLd|jvr|j�tj|jd�d|jvr(|j�tj|jd�d|jvr8|j�tj|jd�d|jvrN|j�tj|jd�dSdSdSdS)N�
TCP_KEEPALIVEZ
tcp_keepaliveZtcp_keepalive_idleZtcp_keepalive_cntZtcp_keepalive_intvl)	rqrhrjrlrsrxZTCP_KEEPALIVE_IDLEZTCP_KEEPALIVE_CNTZTCP_KEEPALIVE_INTVLrwrrrrts"

�
�
��zSREQ._set_tcp_keepalivecCs�t|d�r?t|jjt�r&t|jj���}|D]}t�d|�|j�	|�qn|jjD]}t�d|�|j�	|d�q*|`
dSdS)z.
        delete socket if you have it
        rlzUnregistering socket: %srN)rqr2ri�socketsr9r:�keysr(Ztrace�
unregisterrl�r[ryrrrrr�clear_socket*s
��zSREQ.clear_socketro�<c	Cs�d|i}||d<t|�}|j�|�|j�|jtj�d}	|j�|d�}|d7}|r-n|dkr9t�	d|||�||krK|�
�td�|||���qt
|j���S)	zO
        Takes two arguments, the encryption type and the base payload
        rrrTi�roz5SaltReqTimeoutError: after %s seconds. (Try %s of %s)z3SaltReqTimeoutError: after {} seconds, ran {} tries)r	rr�sendri�registerrh�POLLIN�pollr(�infor}rrFr�recv)	r[rr�tries�timeoutr
ZpkgZtriedZpolledrrrr:s6����z	SREQ.sendcCs(|�dd�}|�di�}|�||||�S)zA
        Detect the encryption type based on the payload
        r�clearr)�getr)r[r
r�r�rrrrr�	send_autoYszSREQ.send_autocCs�t|jjt�r+t|jj���}|D]}|jdur#|�tj	d�|�
�|j�|�qn%|jjD] }|djdurG|d�tj	d�|d�
�|j�|d�q/|jjdurc|j�tj	d�|j�
�|j
jdurp|j
��dSdS)NFror)r2riryr9r:rz�closedrsrhZLINGERrVr{rrrNZtermr|rrr�destroyas&
�
�zSREQ.destroycCs|��dSrd)r�rwrrr�__del__vszSREQ.__del__)rcrrN)ror~)
rHr^r_r`r]�propertyrrrtr}rr�r�r�rrrrrb�s



rb)NF)F)"r`�collections.abcr=rr"�loggingZsalt.transport.framerZsalt.utils.immutabletypesrr8Zsalt.utils.msgpackZsalt.utils.stringutilsZ
salt.defaultsrZsalt.exceptionsrrZsalt.utils.datarrh�ImportError�	getLoggerrHr(r
rrrr	rrYrZrbrrrr�<module>s6�


:X