File manager - Edit - /opt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib/__pycache__/cli.cpython-311.opt-1.pyc
Back
� �Ϟi � � � d Z ddlZddlZddlZddlZddlZddlmZ ej e � � Z dZd� Zd� Z d� Zd d�Zd � ZdS )z� CLI helper utilities for CageFS user commands. Provides functions for: - Re-entering CageFS environment - Calling commands via proxyexec for privilege escalation � N)�clcagefsz/var/.cagefs/.cagefs.tokenc �� � t t d� � 5 } | � � � � � � cddd� � S # 1 swxY w Y dS # t t f$ r Y dS w xY w)zv Read the CageFS token from the token file. Returns: str: The CageFS token, or None if not found �rN)�open�CAGEFS_TOKEN_PATH�read�strip�IOError�OSError)�fs �Copt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib/cli.py�get_cagefs_tokenr s� � �� �#�S� )� )� $�Q��6�6�8�8�>�>�#�#� $� $� $� $� $� $� $� $� $� $� $� $���� $� $� $� $� $� $���W�� � � ��t�t����s3 �A �&A �A � A�A �A�A �A,�+A,c �D � t j � d� � duS )z� Check if the script is running via proxyexec. When running via proxyexec, PROXYEXEC_UID environment variable is set. Returns: bool: True if running via proxyexec, False otherwise � PROXYEXEC_UIDN)�os�environ�get� � r �is_running_via_proxyexecr + s � � �:�>�>�/�*�*�$�6�6r c �� � t � � }|st � d� � dS t j t j � � � � j }t j � � }t t j � � � � }ddd||| |g|z }d|i}t j |t j t j t j |�� � }|� � � |j S )a, Call a command via proxyexec to execute with root privileges. Args: alias: The proxyexec command alias (e.g., "CAGEFSCTL_USER_SITE_ISOLATION_LIST") args_list: Additional arguments to pass Returns: int: Exit code from the proxyexec command, or None on error zFailed to read CageFS tokenNz/usr/sbin/proxyexecz-czcagefs.sock�CAGEFS_TOKEN��stdout�stderr�stdin�env)r �logger�error�pwd�getpwuidr �getuid�pw_name�getcwd�str�getpid� subprocess�Popen�sysr r r �communicate� returncode) �alias� args_list�token�username�cwd�pid�cmdr �ps r �call_via_proxyexecr4 7 s� � � ���E�� ����2�3�3�3��t��|�B�I�K�K�(�(�0�H� �)�+�+�C� �b�i�k�k� � �C� ��m��� �� � ��C� �5� !�C����S�Z�� �#�)�Y\�]�]�]�A��M�M�O�O�O��<�r c �� � | �t j } dg| z }t j |t j t j t j i �� � }|� � � |j S )z� Re-execute inside CageFS when running outside. Args: argv: Command line arguments to pass (defaults to sys.argv) Returns: int: Exit code from the re-executed command Nz/bin/cagefs_enterr ) r) �argvr'