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

�N�gy�@sjdZddlZddlZddlZddlZddlZddlZddlZe�	e
�Zdd�Zdd�Z
dd�Zd	d
�ZdS)z
Utility functions for minions
�Nc	Cszg}tj�|dd�}tj�|�s|St�|�D]"}tj�||�}zt||�}|dur0|�|�Wqty:Yqw|S)z0
    Return the running jobs on this minion
    �cachedir�procN)�os�path�join�isdir�listdir�_read_proc_file�append�OSError)�opts�retZproc_dir�fn_r�data�r�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/minion.py�runnings

��rcCs�tj�|dd|d�}tj�|�}tj�|�st�|�tjj�	|d��}|�
tj�|��Wd�dS1s9wYdS)z(
    Write job information to cache
    rZminion_jobszreturn.pzw+bN)
rrr�dirnamer�makedirs�salt�utils�files�fopen�write�payload�dumps)r�jidr
rZjdir�fp_rrr�
cache_jobs(s
"�rc		Csjt��j}t��}tjj�|d��9}|�	�}|�
�|r#tj�|�}n zt�
|�Wnty9t�d|�Ynw	Wd�dSWd�n1sMwYt|t�sYdStjj�|d�s{zt�
|�WdStyzt�d|�YdSw|�d�r�|�d�|kr�dSn||�d�|kr�zt�
|�WdSty�t�d|�YdSwd�|�d�|�d��}|�d�|ks�||kr�dS|�d�dd	�t��D�vp�|d
d	�t��D�v}|s�|dd	�t��D�v}|�szt�
|�WdSt�yt�d|�YdSwt|��s3|�d�}|�rt�d|�zt�
|�WdSt�y2t�d|�YdSw|S)
z0
    Return a dict of JID metadata, or None
    �rbzUnable to remove proc file %s.N�pid�multiprocessingz	{}-Job-{}rcS�g|]}|j�qSr��name��.0�xrrr�
<listcomp>^s�z#_read_proc_file.<locals>.<listcomp>cSr"rr#r%rrrr(`�cSr"rr#r%rrrr(br)z7PID %s exists but does not appear to be a salt process.)�	threading�current_threadr$r�getpidrrrr�read�closer�loads�remover�log�debug�
isinstance�dict�processZ
os_is_running�get�format�	enumerate�_check_cmdline�warning)	rrr+r r�bufrZthread_name�foundrrrr	4s�
���
��
�������

��r	cCs�tjj��sdS|�d�}|sdStj�d�sdStj�d|�d��}tj�	|�s+dSz-tjj
�|d��}d|��vrE	Wd	�WdSWd	�Wd	S1sQwYWd	St
ybYdSw)
a9
    In some cases where there are an insane number of processes being created
    on a system a PID can get recycled or assigned to a non-Salt process.
    On Linux this fn checks to make sure the PID we are checking on is actually
    a Salt process.

    For non-Linux systems we punt and just return True
    Tr Fz/procz/proc/z/cmdlinerssaltN)rr�platformZis_linuxr6rrrr�isfilerrr-r)rr rrrrrr9vs(	
�&��r9)�__doc__�loggingrr*Zsalt.payloadrZsalt.utils.filesZsalt.utils.platformZsalt.utils.process�	getLogger�__name__r1rrr	r9rrrr�<module>s
B