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

�N�gȖ�@s�dZddlZddlZddlZddlZddlmZddlm	Z
ddlmZdZ
e�e�ZdZdd	�Zd
d�Zdd
�Zdd�Zd*dd�Zd*dd�Zdd�Zdd�Zd+dd�Zd+dd�Zdd�Zdd �Zd,d"d#�Zd,d$d%�Z			!	!		!d-d&d'�Z d(d)�Z!dS).a�	
Starting or restarting of services and daemons
==============================================

Services are defined as system daemons and are typically launched using system
init or rc scripts. This service state uses whichever service module is loaded
on the minion with the virtualname of ``service``. Services can be defined as
either running or dead.

If you need to know if your init system is supported, see the list of supported
:mod:`service modules <salt.modules.service.py>` for your desired init system
(systemd, sysvinit, launchctl, etc.).

Note that Salt's service execution module, and therefore this service state,
uses OS grains to ascertain which service module should be loaded and used to
execute service functions. As existing distributions change init systems or
new distributions are created, OS detection can sometimes be incomplete.
If your service states are running into trouble with init system detection,
please see the :ref:`Overriding Virtual Module Providers <module-provider-override>`
section of Salt's module documentation to work around possible errors.

For services managed by systemd, the systemd_service module includes a built-in
feature to reload the daemon when unit files are changed or extended. This
feature is used automatically by the service state and the systemd_service
module when running on a systemd minion, so there is no need to set up your own
methods of reloading the daemon. If you need to manually reload the daemon for
some reason, you can use the :func:`systemd_service.systemctl_reload <salt.modules.systemd_service.systemctl_reload>` function provided by Salt.

.. note::
    The current status of a service is determined by the return code of the init/rc
    script status command. A status return code of 0 it is considered running.  Any
    other return code is considered dead.

.. code-block:: yaml

    httpd:
      service.running: []

The service can also be set to start at runtime via the enable option:

.. code-block:: yaml

    openvpn:
      service.running:
        - enable: True

By default if a service is triggered to refresh due to a watch statement the
service is restarted. If the desired behavior is to reload the service, then
set the reload value to True:

.. code-block:: yaml

    redis:
      service.running:
        - enable: True
        - reload: True
        - watch:
          - pkg: redis

.. note::

    More details regarding ``watch`` can be found in the
    :ref:`Requisites <requisites>` documentation.

�N)�CommandExecutionError)�get_function_argspec)�booted)Zno_block�unmask�unmask_runtime�servicecCs&dtvrtSdd�t�dtd��fS)zr
    Only make these states available if a service provider has been detected or
    assigned for this minion
    �
service.startFzONo service execution module loaded: check support for service management on {} Zosfinger�os)�__salt__�__virtualname__�formatZ
__grains__�get�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/service.py�__virtual__Ss�rcCspttd�sttdt��i}g}t|�j}tD]}||vr3||vr3tjr+||||<q|�d�	|��q||fS)N�HAS_SYSTEMDz3The '{}' argument is not supported by this platform)
�hasattr�_get_systemd_only�setattrr�_argspec�args�SYSTEMD_ONLYr�appendr)�func�kwargs�ret�warningsZ
valid_argsZsystemd_argrrrrds 

���rcs(|�dg�����fdd�|D��dS)Nrcsg|]}|�vr|�qSrr)�.0�x�Zcurrent_warningsrr�
<listcomp>zsz!_add_warnings.<locals>.<listcomp>)�
setdefault�extend)rrrrr�
_add_warningsxsr#cCsd|d<d�|d�|d<|S)z!
    Warn of potential typo.
    F�resultzUService {} uses non-existent option "enabled".  Perhaps "enable" option was intended?�name�comment)r)rrrr�_enabled_used_error}s

�r'Tc	
Ksni}z
t||�s|WSWnty)}zd|d<|j|d<|WYd}~Sd}~ww||d<dtvs6dtvrY|durCd�|�|d<|S|durPd	�|�|d<|Sd
�|�|d<|Std|fi|��}|r�|durrd�|�|d<|S|dur�i|d<d
�|�|d<|Sd|�d�|d<|Stdr�d|d<d|�d�|d<|SzKtd|fi|��r�i|d<td|fi|��}||kr�d|d|<|dur�d�|�|d<|WS|dur�d�|�|d<|WSd|�d�|d<|WSWnty�}z	|j}WYd}~nd}~wwd}d|d<|du�rd�|�|d<n|du�r d�|�|d<nd�|�|d<|�r5|dd|��7<|S)z
    Enable the service
    Fr$r&Nzservice.enable�service.enabledTz:Enable is not available on this minion, service {} startedzJEnable is not available on this minion, service {} is in the desired statez:Enable is not available on this minion, service {} is deadz-Service {} is already enabled, and is running�changesz:Service {} is already enabled, and is in the desired state�Service z  is already enabled, and is dead�testz set to be enabledz+Service {} has been enabled, and is runningz8Service {} has been enabled, and is in the desired statez has been enabled, and is deadzKFailed when setting service {} to start at boot, but the service is runningzTFailed when setting service {} to start at boot, but the service was already runningzHFailed when setting service {} to start at boot, and the service is deadz#. Additional information follows:

)�
_availabler�strerrorr
r�__opts__)	r%�startedr$rr�exc�before_toggle_enable_status�after_toggle_enable_statusZenable_errorrrr�_enable�s�
�
������
����
������������
�
���r3c
Ks:i}zt||�sd|d<|WSWnty-}zd|d<|j|d<|WYd}~Sd}~ww||d<dtvs:dtvr]|durGd�|�|d<|S|durTd	�|�|d<|Sd
�|�|d<|Stjj��rntd|�dd
v}ntd|�}|r�|dur�d�|�|d<|S|dur�i|d<d�|�|d<|Sd|�d�|d<|St	dr�d|d<d|�d�|d<|Std|fi|��r�i|d<td|�}||kr�d|d|<|dur�d|�d�|d<|S|dur�d|�d�|d<|Sd|�d�|d<|Sd|d<|du�rd�|�|d<|S|du�rd�|�|d<|Sd�|�|d<|S)z
    Disable the service
    Tr$Fr&Nzservice.disablezservice.disabledz;Disable is not available on this minion, service {} startedzKDisable is not available on this minion, service {} is in the desired statez;Disable is not available on this minion, service {} is dead�service.info�	StartType)ZDisabledz.Service {} is already disabled, and is runningr)z;Service {} is already disabled, and is in the desired stater*z! is already disabled, and is deadr+z set to be disabledz" has been disabled, and is runningz/ has been disabled, and is in the desired statez has been disabled, and is deadzCFailed when setting service {} to not start at boot, and is runningzXFailed when setting service {} to not start at boot, but the service was already runningzLFailed when setting service {} to not start at boot, and the service is dead)
r,rr-r
r�salt�utils�platform�
is_windowsr.)r%r/r$rrr0Zbefore_toggle_disable_statusZafter_toggle_disable_statusrrr�_disable�s�
�
������
����
�����
��
��
��	��r:cCsdtvotd�S)Nzservice.offline�r
rrrr�_offlinepsr<cCsPd}dtvr
td|�}ndtvr|td�v}|s&d|d<d|�d�|d<|S)z+
    Check if the service is available
    Fzservice.availablezservice.get_allr$�The named service � is not availabler&r;)r%rZavailrrrr,tsr,c
Ks�|iddd�}dtd<d|vrt|�St|t�rtjj�|�}t�r,d|d<d|d	<|Szt	||�sEt
�d
�rBd|d<d�|�|d	<|WSWnt
yc}zd
|d<|j|d	<|WYd}~Sd}~wwttd|�\}}|rtt||�td||fi|��}	dtvr�td|�}
nd}
d	di}|�dd
�r�t||�dd
��}|	r�d�dd�d|�d�|d	fD��|d	<|dur�|
s�|�t|dfi|���|S|d
ur�|
r�|�t|dfi|���|St
d
r�d|d<d�dd�d|�d�|d	fD��|d	<|Sttd|�\}}|�rt||�tjj���r$|�dd
��r$|�d|�d�i�tjj��}
tjj��}|
�s6|�rW|
�sW|�sId�|�|d	<d
|d<|S|�t|dfi|���d}ztd|fi|��}Wnt
�y�}zd
|d<|j|d	<|WYd}~Sd}~ww|�s�d
|d<d|�d�|d	<|du�r�|�t|d
fdd
i|���|S|d
u�r�|�t|d
fdd
i|���|S|�r�t�|�td||fi|��}dtv�r�td|�}nd}|
|k�s�|	|k�r�|�di��s�||d|<|�r�d|��|d	<nd|�d�|d	<d
|d<|du�r|�t||fd|i|���n|d
u�r1|�t||fd|i|���|�r>d �|d	|�|d	<|�dd
��rRd�|d	|d	g�|d	<|S)!a

    Ensure that the service is running

    name
        The name of the init or rc script used to manage the service

    enable
        Set the service to be enabled at boot time, ``True`` sets the service
        to be enabled, ``False`` sets the named service to be disabled. The
        default is ``None``, which does not enable or disable anything.

    sig
        The string to search for when looking for the service process with ps

    init_delay
        Some services may not be truly available for a short period after their
        startup script indicates to the system that they are. Provide an
        'init_delay' to specify that this state should wait an additional given
        number of seconds after a service has started before returning. Useful
        for requisite states wherein a dependent state might assume a service
        has started but is not yet fully initialized.

    no_block : False
        **For systemd minions only.** Starts the service using ``--no-block``.

        .. versionadded:: 2017.7.0

    timeout
        **For Windows minions only.**

        The time in seconds to wait for the service to start before returning.
        Default is the default for :py:func:`win_service.start
        <salt.modules.win_service.start>`.

        .. versionadded:: 2017.7.9,2018.3.4

    unmask : False
        **For systemd minions only.** Set to ``True`` to remove an indefinite
        mask before attempting to start the service.

        .. versionadded:: 2017.7.0
            In previous releases, Salt would simply unmask a service before
            making any changes. This behavior is no longer the default.

    unmask_runtime : False
        **For systemd minions only.** Set to ``True`` to remove a runtime mask
        before attempting to start the service.

        .. versionadded:: 2017.7.0
            In previous releases, Salt would simply unmask a service before
            making any changes. This behavior is no longer the default.

    wait : 3
        **For systemd minions only.** Passed through when using
        :py:func:`service.status <salt.modules.systemd_service.status>` to
        determine whether the service is running or not.

        .. versionadded:: 2019.2.3

    .. note::
        ``watch`` can be used with service.running to restart a service when
         another state changes ( example: a file.managed state that creates the
         service's config file ). More details regarding ``watch`` can be found
         in the :ref:`Requisites <requisites>` documentation.
    T��r%r)r$r&�running�
service.state�enabledr$�&Running in OFFLINE mode. Nothing to dor&r+NzPService {} not present; if created in this state run, it would have been startedF�service.statusr(rr�
cS�g|]}|r|�qSrr�rZ_frrrr ����zrunning.<locals>.<listcomp>�The service z is already runningcSrGrrrHrrrr rIr*z is set to startr�timeoutzhThe service {} is disabled but enable is not True. Set enable to True to successfully start the service.z failed to startr)zStarted service z {}
Delayed return for {} seconds)�__context__r'�
isinstance�strr6r7�data�is_truer<r,r.r
rrr-rr
r#�unmasked�join�updater3r:r8r9Z	is_darwin�time�sleep)r%�enable�sig�
init_delayrrr0�
status_kwargsr�before_toggle_statusr1Z
unmask_retZstart_kwargs�macosZwindows�func_ret�after_toggle_statusr2rrrrA�s�B


��
��

���
�
���

�
��

�




�
�
��rAc
Ks�|iddd�}dtd<d|vrt|�St|t�rtjj�|�}t�r,d|d<d|d	<|Sz!t	||�sLt
�d
�rEd|d<d�|�|d	<|WSd|d<|WSWnt
yj}zd
|d<|j|d	<|WYd}~Sd}~wwttd|�\}}|r{t||�td||fi|��}	dtvr�tjj��r�td|�ddv}
n	td|�}
nd}
|	s�d|�d�|d	<|dur�|
s�|�t|dfi|���|S|d
ur�|
r�|�t|dfi|���|St
d
r�d|d<d|�d�|d	<|Sttd|�\}}|r�t||�tjj���r|�dd
��r|�d|�d�i�td|fi|��}|�sSd
|d<d|�d�|d	<|du�r>|�t|dfdd
i|���|S|d
u�rQ|�t|dfdd
i|���|S|�r[t�|�td|fi|��}
dtv�rqtd|�}nd}|
|k�s}|	|
k�r�|�di��s�|
|d|<|
�r�d
|d<d|�d�|d	<nd|�d�|d	<|du�r�|�t||
fd|
i|���|S|d
u�r�|�t||
fd|
i|���|S)a"
    Ensure that the named service is dead by stopping the service if it is running

    name
        The name of the init or rc script used to manage the service

    enable
        Set the service to be enabled at boot time, ``True`` sets the service
        to be enabled, ``False`` sets the named service to be disabled. The
        default is ``None``, which does not enable or disable anything.

    sig
        The string to search for when looking for the service process with ps

    init_delay
        Add a sleep command (in seconds) before the check to make sure service
        is killed.

        .. versionadded:: 2017.7.0

    no_block : False
        **For systemd minions only.** Stops the service using ``--no-block``.

        .. versionadded:: 2017.7.0

    timeout
        **For Windows minions only.**

        The time in seconds to wait for the service to stop before returning.
        Default is the default for :py:func:`win_service.stop
        <salt.modules.win_service.stop>`.

        .. versionadded:: 2017.7.9,2018.3.4

    Tr?r@�deadrBrCr$rDr&r+NzPService {} not present; if created in this state run, it would have been stoppedFrEr(r4r5)ZAutoZManualrJz is already deadr*z is set to be killed�service.stoprKz failed to dier)z was killed)rLr'rMrNr6r7rOrPr<r,r.r
rrr-rr
r#r8r9rSr3r:rTrU)r%rVrWrXrrr0rYrrZr1Zstop_kwargsr\r]r2rrrr^is�$


���
��

���


�




�
�

�����r^cKsh|iddd�}dtd<|�t|dfi|���t�d�r2|�d�d	|�d
�kr2d|d<d�|�|d<|S)
aL
    Ensure that the service is enabled on boot, only use this state if you
    don't want to manage the running process, remember that if you want to
    enable a running service to use the enable: True option for the running
    or dead function.

    name
        The name of the init or rc script used to manage the service
    Tr?r@rCrBNr+r&r=r>r$zPService {} not present; if created in this state run, it would have been enabled)rLrSr3r.r
r�r%rrrrrrC
s
��rCcKs2|iddd�}dtd<|�t|dfi|���|S)aG
    Ensure that the service is disabled on boot, only use this state if you
    don't want to manage the running process, remember that if you want to
    disable a service to use the enable: False option for the running or dead
    function.

    name
        The name of the init or rc script used to manage the service
    Tr?r@�disabledrBN)rLrSr:r`rrrra&s
raFc
Cs(|iddd�}dtvrd|d<d|d<|S|rd	nd
}|ddd�i}zTtd||�r5d�||�|d<|WStd
rNd|d<||d<d|�d|��|d<|WStd||�td||�rm||d<d|�d|��|d<|WSd|��|d<|WSty�}zd|d<|j|d<|WYd}~Sd}~ww)a�
    .. versionadded:: 2017.7.0

    .. note::
        This state is only available on minions which use systemd_.

    Ensures that the named service is masked (i.e. prevented from being
    started).

    name
        Name of the service to mask

    runtime : False
        By default, this state will manage an indefinite mask for the named
        service. Set this argument to ``True`` to runtime mask the service.

    .. note::
        It is possible for a service to have both indefinite and runtime masks
        set for it. Therefore, this state will manage a runtime or indefinite
        mask independently of each other. This means that if the service is
        already indefinitely masked, running this state with ``runtime`` set to
        ``True`` will _not_ remove the indefinite mask before setting a runtime
        mask. In these cases, if it is desirable to ensure that the service is
        runtime masked and not indefinitely masked, pair this state with a
        :py:func:`service.unmasked <salt.states.service.unmasked>` state, like
        so:

        .. code-block:: yaml

            mask_runtime_foo:
              service.masked:
                - name: foo
                - runtime: True

            unmask_indefinite_foo:
              service.unmasked:
                - name: foo
                - runtime: False

    .. _systemd: https://freedesktop.org/wiki/Software/systemd/

    Tr?r@�service.masked�,Service masking not available on this minionr&Fr$�runtime masked�masked��old�newzService {} is already {}r+Nr)r*�
 would be zservice.mask� was zFailed to mask service )r
rr.rr-)r%�runtimer�	mask_type�expected_changesr0rrrre9s@+��
��rec
Cs8|iddd�}dtvrd|d<d|d<|S|rd	nd
}|rdnd}|ddd
�i}zVtd||�s=d|�d|��|d<|WStdrVd|d<||d<d|�d|��|d<|WStd||�td||�su||d<d|�d|��|d<|WSd|��|d<|WSty�}zd|d<|j|d<|WYd}~Sd}~ww)aW
    .. versionadded:: 2017.7.0

    .. note::
        This state is only available on minions which use systemd_.

    Ensures that the named service is unmasked

    name
        Name of the service to unmask

    runtime : False
        By default, this state will manage an indefinite mask for the named
        service. Set this argument to ``True`` to ensure that the service is
        runtime masked.

    .. note::
        It is possible for a service to have both indefinite and runtime masks
        set for it. Therefore, this state will manage a runtime or indefinite
        mask independently of each other. This means that if the service is
        indefinitely masked, running this state with ``runtime`` set to
        ``True`` will _not_ remove the indefinite mask.

    .. _systemd: https://freedesktop.org/wiki/Software/systemd/

    Tr?r@rbrcr&Fr$rdrezruntime unmaskedrQrfr*z
 was already r+Nr)rizservice.unmaskrjzFailed to unmask service )r
r.rr-)r%rkrrl�actionrmr0rrrrQ�s<�
��rQc
Ks|iddd�}d}	ttd|�\}
}|rt||�|dkr@d}|d}	td||fi|
��r3td	}
ndd|d
<d|	��|d<|S|d
kr�td||fi|
��r}dtvri|ridtvrb|rbtd}
d}n!td}
d}ndtvrv|rvtd}
d}n
td}
d}ntd}
d}|	s�|d}	n
d|��|d<d|d
<|Stdr�d|d
<d|	��|d<|S|dkr�d	tvr�td	|�t|
|�\}}|r�t||�z
|
|fi|��}Wnty�}zd|d
<|j|d<|WYd}~Sd}~ww|r�t�|�||i|d<||d
<|�rd|	��nd|�d �|d<|S)!a�
    The service watcher, called to invoke the watch command.
    When called, it will restart or reload the named service.

    .. note::
        This state exists to support special handling of the ``watch``
        :ref:`requisite <requisites>`. It should not be called directly.

        Parameters for this function should be set by the watching service
        (e.g. ``service.running``).

    name
        The name of the service to control.

    sfun
        The original function which triggered the mod_watch call
        (`service.running`, for example).

    sig
        The string to search for when looking for the service process with ps.

    reload
        When set, reload the service instead of restarting it
        (e.g. ``service nginx reload``).

    full_restart
        Perform a full stop/start of a service by passing ``--full-restart``.
        This option is ignored if ``reload`` is set and is supported by only a few
        :py:func:`service modules <salt.modules.service>`.

    force
        Use service.force_reload instead of reload (needs reload to be set to True).

    init_delay
        Add a sleep command (in seconds) before the service is restarted/reloaded.
    Tr?r@NrEr^�stopZpedr_r$zService is already r&rAzservice.reloadzservice.force_reloadzforcefully reload�reloadzservice.full_restartz
fully restartzservice.restartZrestartr�startZedz$Unable to trigger watch for service.Fr+zService is set to be r)r*z
Failed to z the service)rr
r#r.rr-rTrU)r%�sfunrWrpZfull_restartrX�forcerrZpast_participlerYrZverbrZfunc_kwargsr$r0rrr�	mod_watch�st.

�

��
�rtc
Ks�|iddd�}|�dd�}ddg}||vrk|�d�rdd	}i}|�d
i�}|�dd�|d<|�dd
�|d<|�dd�|d<|�dd�|d<d|�d|��}|||i|�dd�|d�}	tddi|	��}|S|iddd�S|id�|�dd�S)z�
    Create a beacon to monitor a service based on a beacon state argument.

    .. note::
        This state exists to support special handling of the ``beacon``
        state argument for supported state functions. It should not be called directly.
    Tr?r@rrNrAr^ZbeaconrZbeacon_dataZonchangeonly�delayrZ
emitatstartupFZuncleanshutdownZbeacon_�_�interval�<)r%Zservicesrw�
beacon_modulezbeacon.presentzNot adding beacon.)r%r)r&r$z7service.{} does not work with the beacon state functionr)�popr
Z
__states__r)
r%rrrrZsupported_funcsryrOZ_beacon_dataZbeacon_nameZ
beacon_kwargsrrr�
mod_beaconAs@

����r{)T)NNN)F)NNFFNF)"�__doc__�loggingrTZsalt.utils.datar6Zsalt.utils.platformZsalt.exceptionsrZsalt.utils.argsrrZsalt.utils.systemdrr�	getLogger�__name__�logrrrr#r'r3r:r<r,rAr^rCrarerQrtr{rrrr�<module>sFB


vq

g"

RB
�v