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

�N�g��@s>dZddlZe�e�Zdd�Zdd�Zddd	�Zdd
d�ZdS)
a�
Management of incron, the inotify cron
==============================================

The incron state module allows for user incrontabs to be cleanly managed.

Incron declarations require a number of parameters. The parameters needed
to be declared: ``path``, ``mask``, and ``cmd``. The ``user`` whose incrontab is to be edited
also needs to be defined.

When making changes to an existing incron job, the ``path`` declaration is the unique
factor, so if an existing cron that looks like this:

.. code-block:: yaml

    Watch for modifications in /home/user:
        incron.present:
            - user: root
            - path: /home/user
            - mask:
                - IN_MODIFY
            - cmd: 'echo "$$ $@"'

Is changed to this:

.. code-block:: yaml

    Watch for modifications and access in /home/user:
        incron.present:
            - user: root
            - path: /home/user
            - mask:
                - IN_MODIFY
                - IN_ACCESS
            - cmd: 'echo "$$ $@"'

Then the existing cron will be updated, but if the cron command is changed,
then a new cron job will be added to the user's crontab.

.. versionadded:: 0.17.0

�Ncs�|�d�}|��td|�}|�d�r|dd�}|dD].}||dkrL|d|krL|d	�d������|kr>d
St�fdd�|D��rLd
SqdS)z
    Return the changes
    �,zincron.list_tab�
N���Zcrons�path�cmd�mask�presentcsg|]}|�v�qS�r	)�.0�x�Z	cron_maskr	�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/incron.py�
<listcomp>Asz_check_cron.<locals>.<listcomp>�update�absent)�split�sort�__salt__�endswith�any)�userrrrZarg_mask�lstZcronr	rr
�_check_cron1s

�rcCsZd}tddkr
d}d}ntddkrd}d}nt�d�d	kr$d}d}nd}d}|||fS)
zI
    Returns the proper group owner and path to the incron directory
    �root�osZFreeBSDZwheelz/var/spool/incronZOpenBSDZcrontabZ	os_family�Solaris)Z
__grains__�get)�owner�groupZcrontab_dirr	r	r
�_get_cron_infoFs
rrcCs6d�|�}id|dd�}tdrIt||||�}d|d<|dkr)d	|�d
�|d<|S|dkr;d|d<d	|�d
�|d<|S|dkrGd	|�d�|d<|Std||||d�}|dkrad	|�d
�|d<|S|dkrxd	|�d|�d�|d<||i|d<|S|dkr�d	|�d�|d<||i|d<|Sd�|||�|d<d|d<|S)a�
    Verifies that the specified incron job is present for the specified user.
    For more advanced information about what exactly can be set in the cron
    timing parameters, check your incron system's documentation. Most Unix-like
    systems' incron documentation can be found via the incrontab man page:
    ``man 5 incrontab``.

    name
        Unique comment describing the entry

    path
        The path that should be watched

    user
        The name of the user who's crontab needs to be modified, defaults to
        the root user

    mask
        The mask of events that should be monitored for

    cmd
        The cmd that should be executed

    r�T)�changes�comment�name�result�testNr$r�Incron z is set to be addedr"rz already presentrz is set to be updatedzincron.set_job�rrrr�newz
 added to z's incrontabr!�updatedz updatedz5Incron {} for user {} failed to commit with error 
{}F��joinZ__opts__rr�format�r#rrrr�ret�status�datar	r	r
rZs@
���rcCs�d�|�}|didd�}tdr?t||||�}d|d<|dkr-d|d<d	|�d
�|d<|S|dks5|d
kr=d	|�d�|d<|Std||||d�}|dkrWd	|�d�|d<|S|dkrnd	|�d|�d�|d<||i|d<|Sd�|||�|d<d|d<|S)a�
    Verifies that the specified incron job is absent for the specified user; only
    the name is matched when removing a incron job.

    name
        Unique comment describing the entry

    path
        The path that should be watched

    user
        The name of the user who's crontab needs to be modified, defaults to
        the root user

    mask
        The mask of events that should be monitored for

    cmd
        The cmd that should be executed

    rTr )r#r$r!r"r%Nr$rr&z
 is absentr"rrz is set to be removedz
incron.rm_jobr'z already absentZremovedz removed from z
's crontabr!z4Incron {} for user {} failed to commit with error {}Fr*r-r	r	r
r�s2
��r)r)	�__doc__�logging�	getLogger�__name__�logrrrrr	r	r	r
�<module>s+

=