HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/systemd.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
zddlZWney5dZYnwe�
e�Zddd�Zddd�Zddd	�Zdd
d�Zddd
�Zdd�Zdd�Zdd�Zdd�ZdS)z%
Contains systemd related help files
�N)�SaltInvocationErrorcCs�d}t|ttjjjf�r||vr||Sn|durtd��z	tt�	d��}Wnt
y1d}Ynwz|||<W|StyCY|Sw)a@
    Return True if the system was booted with systemd, False otherwise.  If the
    loader context dict ``__context__`` is passed, this function will set the
    ``salt.utils.systemd.booted`` key to represent if systemd is running and
    keep the logic below from needing to be run again during the same salt run.
    zsalt.utils.systemd.bootedN�&context must be a dictionary if passedz/run/systemd/systemF)�
isinstance�dict�salt�loader�context�NamedLoaderContextr�bool�os�stat�OSError�	TypeError�r�
contextkey�ret�r�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/systemd.py�booteds&��
��rcCsvd}t|ttjjjf�r||vr||Sn|durtd��t|�o(tjj	�
d�}z|||<W|Sty:Y|Sw)zJReturn True if systemd is in offline mode

    .. versionadded:: 3004
    zsalt.utils.systemd.offlineNr�	systemctl)rrrrrr	rr�utils�path�whichrrrrr�offline7s�
��rcCsdd}t|ttjjjf�r||vr||Sn|durtd��tjddgddd�}d	|j	v}|||<|S)
z�Return True if systemd status succeeds. When False, the system may have
    been booted with systemd but systemd is in a degraded state.

    .. versionadded:: 3006.0
    zsalt.utils.systemd.statusNrr�statusFT)�check�capture_outputs9Failed to get D-Bus connection: No such file or directory)
rrrrrr	r�
subprocess�run�stderr)rr�procrrrrrOs ���rc
Cs�d}t|ttjjjf�r||vr||Sn|durtd��tjddgdtj	tj
d���d}tjj
�|�}ztt�d	|��d��d
��}WntttfyYt�d|�YdSwz|||<W|StykY|Sw)z_
    Attempts to run systemctl --version. Returns None if unable to determine
    version.
    zsalt.utils.systemd.versionNrrz	--versionT)�	close_fds�stdoutrrz\w+ ([0-9]+)�zPUnable to determine systemd version from systemctl --version, output follows:
%s)rrrrrr	rr�Popen�PIPE�STDOUT�communicaterZstringutilsZto_str�int�re�search�
splitlines�group�AttributeError�
IndexError�
ValueError�log�errorr)rrr"Zoutstrrrrr�versionis@���"��
��r2cCs4t|�sdSt|�}|durdSt|�r|dkSdS)z�
    Scopes were introduced in systemd 205, this function returns a boolean
    which is true when the minion is systemd-booted and running systemd>=205.
    FN��)rr2r)rZ_sd_versionrrr�	has_scope�sr4cCstrt|�St|�S)z�
    Check if a PID belongs to a systemd service and return its name.
    Return None if the PID does not belong to a service.

    Uses DBUS if available.
    )�dbus�_pid_to_service_dbus�_pid_to_service_systemctl)�pidrrr�pid_to_service�sr9c	Csxddddt|�g}ztj|dddd�}tjj�|j�}Wn
ttj	fy)YdSw|�
d�}|r:|�d�r:t|�SdS)	Nrz--output�jsonrT)r�textrZ
_SYSTEMD_UNIT�.service)
�strrrrrr:Z	find_jsonr"r/�CalledProcessError�get�endswith�
_strip_suffix)r8Zsystemd_cmdZsystemd_outputZstatus_json�namerrrr7�s ��
r7c	Cs�t��}|�dd�}t�|d�}z*|�|�}|�d|�}t�|d�}|�dd�}t|�}|r8|�d�r8t|�WSWdStj	yEYdSw)	zq
    Use DBUS to check if a PID belongs to a running systemd service and return the service name if it does.
    zorg.freedesktop.systemd1z/org/freedesktop/systemd1z org.freedesktop.systemd1.Managerzorg.freedesktop.DBus.Propertieszorg.freedesktop.systemd1.UnitZIdr<N)
r5Z	SystemBusZ
get_objectZ	InterfaceZGetUnitByPIDZGetr=r@rAZ
DBusException)	r8ZbusZsystemd_objectZsystemdZservice_pathZservice_objectZ
service_props�service_namerBrrrr6�s&�
�
�r6cCs|dd�S)z<
    Strip ".service" suffix from a given service name.
    Ni����r)rCrrrrA�srA)N)�__doc__�loggingrr)rZsalt.loader.contextrZsalt.utils.pathZsalt.utils.stringutilsZsalt.exceptionsrr5�ImportError�	getLogger�__name__r0rrrr2r4r9r7r6rArrrr�<module>s0�





%