HEX
Server: LiteSpeed
System: Linux server232.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User: heatxmsi (538)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cloudlinux/venv/lib/python3.11/site-packages/lve_utils/__pycache__/cagefs.cpython-311.pyc
�

��
j
��B�dZddlZddlZddlZddlZdZdZddd�Zd�ZdS)	z�Helpers for CageFS interaction from lvectl / lvdctl.

Kept in python_lve to avoid a hard dependency on securelve: lve-utils
is installed on systems without CageFS, so anything we call here must
degrade to a no-op when CageFS is absent.
�Nz/usr/sbin/cagefsctlz/etc/cagefs/proxy.commandsz(/usr/share/lve-utils/lvd-registry-helperz&/usr/share/lve-utils/lvd-limits-helper)�LVD_REGISTRY_HELPER�LVD_LIMITS_HELPERc�n�tj�t��sdS	t	t
dd���5}|���}ddd��n#1swxYwYn#t$rd}YnwxYw|}t�	��D]Q\}}||vr�
tj�|��s�*|r|�
d��s|dz
}||�d|�d�z
}�R||krdStjdt
��tj�
t
��}tj|d	�
��tj|d���\}}	tj|d
d���5}|�|��ddd��n#1swxYwYtj|t
��nB#t($r5tj�|��rtj|���wxYwt-jtdgt,jt,jd���dS)a5Register LVD helper proxyexec entries in /etc/cagefs/proxy.commands.

    No-op when CageFS is not installed (cagefsctl binary absent) or when
    the entries are already present. When entries are added, runs
    ``cagefsctl --update-wrappers`` so the in-CageFS proxyexec wrappers
    appear immediately.
    N�rzutf-8)�encoding��
�=zRegistering LVD helpers in %sT)�exist_okz.proxy.commands.)�dir�prefix�wz--update-wrappersF)�stdout�stderr�check)�os�path�exists�CAGEFSCTL_TOOL�open�PROXY_COMMANDS_PATH�read�FileNotFoundError�LVD_PROXY_ENTRIES�items�endswith�logging�info�dirname�makedirs�tempfile�mkstemp�fdopen�write�replace�
BaseException�unlink�
subprocess�run�DEVNULL)�f�content�new_content�key�binary�	proxy_dir�fd�tmp_paths        �G/opt/cloudlinux/venv/lib64/python3.11/site-packages/lve_utils/cagefs.py�ensure_lvd_proxy_commandsr4!s����7�>�>�.�)�)�����
�%�s�W�
=�
=�
=�	���f�f�h�h�G�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	����������������K�(�.�.�0�0�+�+���V��+�����w�~�~�f�%�%�	���	 �{�3�3�D�9�9�	 ��4��K��#�*�*��*�*�*�*����g������L�0�2E�F�F�F����� 3�4�4�I��K�	�D�)�)�)�)��#�	�:L�M�M�M�L�B���
�Y�r�3��
1�
1�
1�	!�Q�
�G�G�K� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�
�
�8�0�1�1�1�1������
�7�>�>�(�#�#�	 ��I�h����
�����
�N�	�,�-��!��!��	�����sd�A,�A �A,� A$�$A,�'A$�(A,�,A;�:A;�!G�8F�G�F�G�!F�"G�?G?)	�__doc__rrr(r!rrrr4��r3�<module>r8st��������	�	�	�	���������'��2��F�A����1�1�1�1�1r7