Sid Gifari From Gifari Industries - BD Cyber Security Team
Home
/
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
lve_utils
/
__pycache__
/
✏️
Editing: cagefs.cpython-311.opt-1.pyc
� �@�jT � �D � d Z ddlZddlZddlZddlZdZdZdddd�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-helperz%/usr/share/lve-utils/lvd-stats-helper)�LVD_REGISTRY_HELPER�LVD_LIMITS_HELPER�LVD_STATS_HELPERc �n � t j � t � � sdS t t dd�� � 5 } | � � � }ddd� � n# 1 swxY w Y n# t $ r d}Y nw xY w|}t � � � D ]Q\ }}||v r� t j � |� � s�*|r|� d� � s|dz }||� d|� d�z }�R||k rdS t j dt � � t j � t � � }t j |d � � � t j |d�� � \ }} t j |d d�� � 5 } | � |� � ddd� � n# 1 swxY w Y t j |t � � nB# t( $ r5 t j � |� � rt j |� � � w xY wt- j t dgt, j t, j d�� � dS )a5 Register 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 �py/lve_utils/cagefs.py�ensure_lvd_proxy_commandsr5 "