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

�N�g�(�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZe�e
�ZdZdd�Zdd�Z				
			
	ddd�Z	ddd�Zddd�Zddd�ZdS)z-
Publish a command from a minion to a target
�N)�SaltInvocationError�SaltReqTimeoutError�publishcCst�dd�tjjvrtSdS)N�	transport�F)�__opts__�get�saltrZ
TRANSPORTS�__virtualname__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/publish.py�__virtual__s
���r
cCs.tjj�|�}|dur
gSt|t�s|gS|S)zC
    yamlify `arg` and ensure its outermost datatype is a list
    N)r	�utils�argsZyamlify_arg�
isinstance�list)�argZ	yaml_argsrrr�_parse_argss
r�globr��cleanFc	s�dtvrt�d�iS|�d�rt�d�iSt|�}�rQdtvr&tdd���fdd	�tdD�}	|	s=td
��td���t|	�dkrLt�	d�td�|	�
�}
ntd}
t�d
||
�tj�
t�}|�d�}d||||||||tdt�dg�d�}
tjjjjt|
d���}z|�|
�}Wnty�d|�d�YWd�Sw|s�iWd�S|�r.d}t|d�}t�}d}||A�r-dtd||dd�}
|�|
�}t|���}d}||kr�d}n|||kr�|s�iWd�Sd}|�r |dk�ri}|D]}||d ||<�q|Wd�S|Wd�S|d}t�|�||As�n>t�t|��dtd||dd�}
|�|
�}|dk�rci}|D]}||d ||<�qN|Wd�S|Wd�SWd�dS1�sxwYdS)!a
    Publish a command from the minion out to other minions, publications need
    to be enabled on the Salt master and the minion needs to have permission
    to publish the command. The Salt master will also prevent a recursive
    publication loop, this means that a minion cannot command another minion
    to command another minion as that would create an infinite command loop.

    The arguments sent to the minion publish function are separated with
    commas. This means that for a minion executing a command with multiple
    args it will look like this::

        salt system.example.com publish.publish '*' user.add 'foo,1020,1020'

    CLI Example:

    .. code-block:: bash

        salt system.example.com publish.publish '*' cmd.run 'ls -la /tmp'
    �
master_urizSCannot run publish commands without a connection to a salt master. No command sent.zpublish.z*Cannot publish publish calls. Returning {}Zmaster_uri_listzVCould not find list of masters in minion configuration but `via_master` was specified.)�messagecs g|]}d��d�|vr|�qS)z//�:r)�.0Zmaster��
via_masterrr�
<listcomp>^s
�z_publish.<locals>.<listcomp>z[Could not find match for {} in list of configured masters {} when using `via_master` option�z]The `via_master` flag found more than one possible match found for %s when evaluating list %szPublishing '%s' to %s�saltZ
minion_pub�id�no_parse)�cmd�funr�tgt�tgt_type�ret�tok�tmo�formr r!)r�'z' publish timed outNg333333�?ZminionsrZpub_ret�jid)r"r r'r+FTrr&)r�log�error�
startswith�inforr�format�len�warning�popr	�crypt�SAuth�	gen_tokenr�channel�client�
ReqChannel�factory�sendr�set�keys�time�sleep�float)r$r#rr%�returner�timeoutr)�waitrZmatching_master_urisr�authr'�loadr7Z	peer_dataZ
loop_intervalZmatched_minionsZreturned_minionsZloop_counterr&Zend_loopZcret�hostrrr�_publish*s��

�
����


�
���

�
� 
�)�*
���

�;��$rGcCst||||||dd|d�	S)ah
    Publish a command from the minion out to other minions.

    Publications need to be enabled on the Salt master and the minion
    needs to have permission to publish the command. The Salt master
    will also prevent a recursive publication loop, this means that a
    minion cannot command another minion to command another minion as
    that would create an infinite command loop.

    The ``tgt_type`` argument is used to pass a target other than a glob into
    the execution, the available options are:

    - glob
    - pcre
    - grain
    - grain_pcre
    - pillar
    - pillar_pcre
    - ipcidr
    - range
    - compound

    .. versionchanged:: 2017.7.0
        The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
        releases must use ``expr_form``.

    Note that for pillar matches must be exact, both in the pillar matcher
    and the compound matcher. No globbing is supported.

    The arguments sent to the minion publish function are separated with
    commas. This means that for a minion executing a command with multiple
    args it will look like this:

    .. code-block:: bash

        salt system.example.com publish.publish '*' user.add 'foo,1020,1020'
        salt system.example.com publish.publish 'os:Fedora' network.interfaces '' grain

    CLI Example:

    .. code-block:: bash

        salt system.example.com publish.publish '*' cmd.run 'ls -la /tmp'


    .. admonition:: Attention

        If you need to pass a value to a function argument and that value
        contains an equal sign, you **must** include the argument name.
        For example:

        .. code-block:: bash

            salt '*' publish.publish test.kwarg arg='cheese=spam'

        Multiple keyword arguments should be passed as a list.

        .. code-block:: bash

            salt '*' publish.publish test.kwarg arg="['cheese=spam','spam=cheese']"


    When running via salt-call, the `via_master` flag may be set to specific which
    master the publication should be sent to. Only one master may be specified. If
    unset, the publication will be sent only to the first master in minion configuration.
    rT)rr%rArBr)rCr�rG)r$r#rr%rArBrrrrr�sE�c
Cst||||||ddd�S)a
    Return the full data about the publication, this is invoked in the same
    way as the publish function

    CLI Example:

    .. code-block:: bash

        salt system.example.com publish.full_data '*' cmd.run 'ls -la /tmp'

    .. admonition:: Attention

        If you need to pass a value to a function argument and that value
        contains an equal sign, you **must** include the argument name.
        For example:

        .. code-block:: bash

            salt '*' publish.full_data test.kwarg arg='cheese=spam'

    �fullT)rr%rArBr)rCrH)r$r#rr%rArBrrr�	full_datas�rJc
Cs�t|�}dtvr
dSt�d|td�tj�t�}|�d�}d||||tdt�dg�d�}tj	j
j�t��%}z
|�
|�WWd	�StyZd
|�d�YWd	�Sw1s^wYd	S)z�
    Execute a runner on the master and return the data from the runner
    function

    CLI Example:

    .. code-block:: bash

        salt publish.runner manage.down
    rzDNo access to master. If using salt-call with --local, please remove.zPublishing runner '%s' to %srZ
minion_runnerr r!)r"r#rr'r(r r!Nr*z' runner publish timed out)rrr,r/r	r4r5r6rr7r8r9r:r;r)r#rrBrDr'rEr7rrr�runner?s.

�

���rK)NrrrrFN)NrrrN)Nrrr)Nr)�__doc__�loggingr>Zsalt.channel.clientr	Z
salt.cryptZsalt.payloadZsalt.transportZsalt.utils.argsZsalt.exceptionsrr�	getLogger�__name__r,r
r
rrGrrJrKrrrr�<module>s4

�#
�
R"