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__/environ.cpython-310.pyc
o

�N�g�#�@sndZddlZddlZddlZe�e�Zdd�Zddd�Z		ddd	�Z
ddd�Zdd
d�Zddd�Z
dd�ZdS)zX
Support for getting and setting the environment variables
of the current salt process.
�NcCsdS)zB
    No dependency checks, and not renaming, just return True
    T�rrr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/environ.py�__virtual__srFc
CsRtjj��}|rd}d}|dkrd}d}t|t�s t�dt|�|dura|dur_zt	j
�|d�|rA|rAtd	|||�td
�WdSt
y^}zt�dt||�WYd}~dSd}~wwd}t|t�r�z|t	j
|<|r~|r~td
||||�td
�t	j
|WSt
y�}zt�dt||�WYd}~dSd}~wwt�dt||�dS)a
    Set a single salt process environment variable. Returns True
    on success.

    key
        The environment key to set. Must be a string.

    val
        The value to set. Must be a string or False. Refer to the
        'false_unsets' parameter for behavior when set to False.

    false_unsets
        If val is False and false_unsets is True, then the key will be
        removed from the salt processes environment dict entirely.
        If val is False and false_unsets is not True, then the key's
        value will be set to an empty string.
        Default: False.

    permanent
        On Windows minions this will set the environment variable in the
        registry so that it is always added as an environment variable when
        applications open. If you want to set the variable to HKLM instead of
        HKCU just pass in "HKLM" for this parameter. On all other minion types
        this will be ignored. Note: This will only take affect on applications
        opened after this has been set.

    CLI Example:

    .. code-block:: bash

        salt '*' environ.setval foo bar
        salt '*' environ.setval baz val=False false_unsets=True
        salt '*' environ.setval baz bar permanent=True
        salt '*' environ.setval baz bar permanent=HKLM
    ZHKCUZEnvironmentZHKLMz<SYSTEM\CurrentControlSet\Control\Session Manager\Environment�-%s: 'key' argument is not a string type: '%s'FTNzreg.delete_valuez&win_functions.broadcast_setting_changez<%s: Exception occurred when unsetting environ key '%s': '%s'�z
reg.set_valuez:%s: Exception occurred when setting environ key '%s': '%s'�>%s: 'val' argument for key '%s' is not a string or False: '%s')�salt�utils�platform�
is_windows�
isinstance�str�log�debug�__name__�os�environ�popZ	__utils__�	Exception�error)�key�val�false_unsets�	permanentrZpermanent_hiveZ
permanent_key�excrrr�setvalsj$�

���	


���	�rc	s�i}t�t�st�dt��dS|dur-�fdd�tjD�}|D]}t|d||d�||<q ���D],\}}t|t	�rDt|||d�||<q1|durSt||||d�||<q1t�dt||�dS|durnt
d�|||d	�d
�|S)a�
    Set multiple salt process environment variables from a dict.
    Returns a dict.

    environ
        Must be a dict. The top-level keys of the dict are the names
        of the environment variables to set. Each key's value must be
        a string or False. Refer to the 'false_unsets' parameter for
        behavior when a value set to False.

    false_unsets
        If a key's value is False and false_unsets is True, then the
        key will be removed from the salt processes environment dict
        entirely. If a key's value is False and false_unsets is not
        True, then the key's value will be set to an empty string.
        Default: False

    clear_all
        USE WITH CAUTION! This option can unset environment variables
        needed for salt to function properly.
        If clear_all is True, then any environment variables not
        defined in the environ dict will be deleted.
        Default: False

    update_minion
        If True, apply these environ changes to the main salt-minion
        process. If False, the environ changes will only affect the
        current salt subprocess.
        Default: False

    permanent
        On Windows minions this will set the environment variable in the
        registry so that it is always added as an environment variable when
        applications open. If you want to set the variable to HKLM instead of
        HKCU just pass in "HKLM" for this parameter. On all other minion types
        this will be ignored. Note: This will only take affect on applications
        opened after this has been set.

    CLI Example:

    .. code-block:: bash

        salt '*' environ.setenv '{"foo": "bar", "baz": "quux"}'
        salt '*' environ.setenv '{"a": "b", "c": False}' false_unsets=True
    z*%s: 'environ' argument is not a dict: '%s'FTcsg|]}|�vr|�qSrr)�.0r�rrr�
<listcomp>�szsetenv.<locals>.<listcomp>)rrz
event.fire)rr�	clear_allrZenviron_setenv)r�dictrrrrrr�itemsr
Z__salt__)	rrrZ
update_minionr�retZto_unsetrrrrr�setenvps<0

���	r#rcCs*t|t�st�dt|�dStj�||�S)a^
    Get a single salt process environment variable.

    key
        String used as the key for environment lookup.

    default
        If the key is not found in the environment, return this value.
        Default: ''

    CLI Example:

    .. code-block:: bash

        salt '*' environ.get foo
        salt '*' environ.get baz default=False
    rF)rr
rrrrr�get)r�defaultrrrr$�s
r$cCs^t|t�st�dt|�dSztj|}|dur"||krWdSWdSWdSty.YdSw)a�
    Determine whether the key exists in the current salt process
    environment dictionary. Optionally compare the current value
    of the environment against the supplied value string.

    key
        Must be a string. Used as key for environment lookup.

    value:
        Optional. If key exists in the environment, compare the
        current value with this value. Return True if they are equal.

    CLI Example:

    .. code-block:: bash

        salt '*' environ.has_value foo
    rFNT)rr
rrrrr�KeyError)r�valueZcur_valrrr�	has_value�s

���r(cCs\i}g}t|t�r|�|�nt|t�r|}nt�dt|�|D]}tj�	||�||<q |S)a�
    Get one or more salt process environment variables.
    Returns a dict.

    keys
        Either a string or a list of strings that will be used as the
        keys for environment lookup.

    default
        If the key is not found in the environment, return this value.
        Default: ''

    CLI Example:

    .. code-block:: bash

        salt '*' environ.item foo
        salt '*' environ.item '[foo, baz]' default=None
    z6%s: 'keys' argument is not a string or list type: '%s')
rr
�append�listrrrrrr$)�keysr%r"Zkey_listrrrr�item�s

�r,cCs
ttj�S)z�
    Return a dict of the entire environment set for the salt process

    CLI Example:

    .. code-block:: bash

        salt '*' environ.items
    )r rrrrrrr!!s

r!)FF)FFFF)r)N)�__doc__�loggingrZsalt.utils.platformr�	getLoggerrrrrr#r$r(r,r!rrrr�<module>s

\
�
T

"#