????
| Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/__pycache__/ |
| Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/__pycache__/manager.cpython-311.pyc |
�
�j&X � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl
mZ ddlm
Z
ddlmZmZ dd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ddlmZmZmZ ddlm Z m!Z!m"Z# G d� d� � Z$dd�Z%dS )zA
This module contains classes implementing SSA Manager behaviour
� N)�contextmanager)�iglob)�
disable_quota)�Tuple� )�load_validated_parser�load_configuration)� flag_file)�SSAManagerError)�ssa_version)�
AutoTracer)�
DecisionMaker)�
INI_FILE_NAME�INI_USER_LOCATIONS_BASE�is_excluded_path)�$copy_inis_to_website_isolation_paths�(remove_inis_from_website_isolation_paths�regenerate_inis_for_userc �" � e Zd ZdZd� Zd� Zedefd�� � Ze de
fd�� � Ze defd�� � Z
e defd�� � Zd edefd
�Z d.dedej fd
�Zdedefd�Zdefd�Zdefd�Zdefd�Zdefd�Zdefd�Zdede
fd�Zdededefd�Zdedefd�Zdeeeef ef fd�Z e!d� � � Z"dedededd fd!�Z#d/d"�Z$deeeef ef fd#�Z%d/d$�Z&d/d%�Z'd/d&�Z(defd'�Z)d/d(�Z*d/d)�Z+defd*�Z,d/d+�Z-d,edd fd-�Z.d S )0�Managerz
SSA Manager class.
c �� � t j d� � | _ t | _ ddg| _ ddg| _ d| _ d| _ t | _
t t t j f| _ d S )N�managerz!usr/lib64/php/modules/clos_ssa.soz0usr/lib/x86_64-linux-gnu/php/modules/clos_ssa.sozlib64/php/modules/clos_ssa.soz,lib/x86_64-linux-gnu/php/modules/clos_ssa.soz lib/php/extensions/*/clos_ssa.so)z /opt/alt/php[0-9][0-9]/link/confz+/opt/cpanel/ea-php[0-9][0-9]/root/etc/php.dz$/opt/plesk/php/[0-9].[0-9]/etc/php.dz'/usr/local/php[0-9][0-9]/lib/php.conf.dzM/usr/share/cagefs/.cpanel.multiphp/opt/cpanel/ea-php[0-9][0-9]/root/etc/php.dzA/usr/share/cagefs-skeleton/usr/local/php[0-9][0-9]/lib/php.conf.d)�logging� getLogger�loggerr �
ini_file_name�module_patterns_with_usr�module_patterns_no_usr�module_glob_pattern_directadmin�wildcard_ini_locationsr �wildcard_ini_user_locations�OSError�
ValueError�
subprocess�SubprocessError�subprocess_errors��selfs �B/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/manager.py�__init__zManager.__init__- sz � ��'� �2�2���*���
0�>�)
��%�
,�:�'
��#� 0R��,�'
��#� ,C��(��Z��!;�"
����� c �J � t j � � } t j |� � j }n# t
$ r d}Y nw xY wd� d� |� � � D � � � � }| j � d|||||� � d S # t
$ r Y d S w xY w)Nz <unknown>� c 3 �* K � | ]\ }}|�d |��V � �dS )�=N� ��.0�k�vs r) � <genexpr>z!Manager._audit.<locals>.<genexpr>P sB � � � � $>� $>�%)�Q��1�1�1�a�a� �$>� $>� $>� $>� $>� $>r+ z0[audit] operation=%s status=%s uid=%d user=%s %s)
�os�getuid�pwd�getpwuid�pw_name� Exception�join�itemsr �info)r( � operation�status�details�uid�username�detail_partss r) �_auditzManager._auditI s� � � ��)�+�+�C�
'��<��,�,�4�����
'�
'�
'�&����
'�����8�8� $>� $>�-4�]�]�_�_�$>� $>� $>� >� >�L��K���B��6�3��,�
@�
@�
@�
@�
@�� � � � ��D�D� ���s- �B �0 �B �?�B �?�AB �
B"�!B"�returnc � � ddi}|� d� |� � � D � � � � t j |� � S )z@
Form a success json response with given kwargs
�result�successc � � i | ]\ }}||�� S r0 r0 r1 s r) �
<dictcomp>z$Manager.response.<locals>.<dictcomp>^ s � �=�=�=�d�a��Q��=�=�=r+ )�updater= �json�dumps)�args�kwargs�raw_responses r) �responsezManager.responseX sI � �
!�)�,�����=�=�f�l�l�n�n�=�=�=�>�>�>��z�,�'�'�'r+ c �J � t j � t � � S )z
Is SSA enabled
)r6 �path�isfiler
r'