ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/xray/manager/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/xray/manager/__pycache__/cpanel.cpython-311.pyc

�

��f ����dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZmZddlmZd	d
lmZmZd	dlmZd	dlmZmZd
dlmZGd�de��ZdS)zN
This module contains classes implementing X-Ray Manager behaviour
for cPanel
�N)�ChainMap)�quote)�Optional)�WhmApiError�
WhmApiRequest)�get_cl_version�is_litespeed_running)�
phpinfo_utils�)�XRayManagerError�XRayMissingDomain)�
DomainInfo)�user_mode_verification�with_fpm_reload_restricted�)�BaseManagerc	��eZdZdZdddddddd	d
�Z	e��dkrded
<ded<ded<n#e$rYnwxYwdefd�Zde	de
e	fd�Z	d!de	dede
fd�Zeede	de
fd�����Zde	defd�Zde
defd�Zde
de	fd �ZdS)"�
CPanelManagerzB
    Class implementing an X-Ray manager behaviour for cPanel
    z#/opt/cpanel/ea-php54/root/etc/php.dz#/opt/cpanel/ea-php55/root/etc/php.dz#/opt/cpanel/ea-php56/root/etc/php.dz#/opt/cpanel/ea-php70/root/etc/php.dz#/opt/cpanel/ea-php71/root/etc/php.dz#/opt/cpanel/ea-php72/root/etc/php.dz#/opt/cpanel/ea-php73/root/etc/php.dz#/opt/cpanel/ea-php74/root/etc/php.d)zea-php54zea-php55zea-php56zea-php70zea-php71zea-php72zea-php73zea-php74�cl6z#/opt/cpanel/ea-php80/root/etc/php.dzea-php80z#/opt/cpanel/ea-php81/root/etc/php.dzea-php81z#/opt/cpanel/ea-php82/root/etc/php.dzea-php82�returnc�6�t|j|j��S)z�
        Get supported PHP versions
        :return: a chained map with basic supported versions
                and cPanel supported versions
        )r�VERSIONS�VERSIONS_cPanel)�selfs �J/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/manager/cpanel.py�supported_versionsz CPanelManager.supported_versions9s ����
��,�.�.�	.��domain_namec�8�	td���|������}|ddS#t$rJ}dt	|��vr.|j�dd|i���t|��|�Yd	}~d	Sd	}~wwxYw)
z�
        Try to resolve domain_name if it is an alias
        :param domain_name: original domain name
        :return: resolved domain name alias
        �domainuserdata��domain�userdata�
servernamez#system does not have a domain named�#Domain does not exist on the serverr��extraN)r�with_arguments�callr�str�logger�warningr
)rr�result�es    r�
resolve_aliaszCPanelManager.resolve_aliasBs���	4�"� ����n�"�����d�f�f�	
��*�%�l�3�3���	�	�	�4��A���>�>���#�#�$I�+8�+�*F�$�H�H�H�'��4�4�!�;��4�4�4�4�4�����
	���s�5A�
B�?B�BN�name�domains_datac����t�fd�|D��d��}|�-|j�dd�i���t����|jr\tj|d|r|n����}t|r|n�|�d��|j	d	|d|j
�
��St|r|n�|d|dt��s|dnd
d
���S)a
        Try to find given name among known domains
        :param name: name  of domain to find
        :param domains_data: list of known domains
        :param original_name: original domain name (in case of alias resolving)
        :return: a DomainInfo object
        c3�4�K�|]}|d�k�|V��dS)�vhostN�)�.0�itemr0s  �r�	<genexpr>z-CPanelManager.check_domain.<locals>.<genexpr>as>�����
�
���G�}��$�$�
�$�$�$�$�
�
rNr%rr&�accountr!zea-phpT)r0�panel_php_version�php_ini_scan_dir�is_selector_applied�user�	panel_fpm�version�php_fpmF)r0r:r=r>r<)�nextr+r,r
�phpinfo_moder
�get_php_configurationr�get_full_php_version�absolute_ini_scan_dir�
is_php_fpmr	)rr0r1�
original_namer"�configs `    r�check_domainzCPanelManager.check_domainXs_����
�
�
�
�)�
�
�
�����
�>��K��� E�'4�d�&;�
 �
=�
=�
=�#�D�)�)�)���	�"�8��y�!�(5�?�}�}�4�A�A�A�F��&3�=�]�]��"(�"=�"=�h�"G�"G�!'�!=�%)��I�&� �+�
�
�
�

��&3�=�]�]��"(��"3��I�&�&:�&<�&<�H�&����BG�$)�
���
rc��td�����}|d}	|�||��}n=#t$r0|�|��}|�|||���}YnwxYw|S)a
        Retrieve information about given domain from control panel environment:
        PHP version, user of domain.
        Try to resolve alias if domain was not found in API response
        :param domain_name: name of domain
        :return: a DomainInfo object
        �php_get_vhost_versions�versions)rG)rr)rIrr/)rrr-�
domain_php�_info�aliass      r�get_domain_infozCPanelManager.get_domain_info�s����$�
�
�
�$�&�&�	��J�'�
�	A��%�%�k�:�>�>�E�E���	A�	A�	A��&�&�{�3�3�E��%�%�e�Z�4?�&�A�A�E�E�E�	A����
�s�A�7A<�;A<�domain_php_versionc�h�td�����}|d}d|vo||kS)a$
        Check if given domain uses system default version.
        And system default is not alt-php.
        If yes, then it means that selector could be applied for given domain
        :param domain_php_version: PHP version of domain
        :return: True if yes, False otherwise
        �php_get_system_default_versionr?zalt-php)rr))rrQr-�default_phps    r�&domain_default_version_allows_selectorz4CPanelManager.domain_default_version_allows_selector�sD���,�
�
�
�$�&�&�	��Y�'����+�Q��?Q�0Q�Qr�domain_infoc�`�|j}|�|��p
||jko|jS)z�
        Check if selector is enabled specifically for panel
        Required to be implemented by child classes
        :param domain_info: a DomainInfo object
        :return: True if yes, False otherwise
        )r:rU�selector_php_versionr>)rrVrQs   r�panel_specific_selector_enabledz-CPanelManager.panel_specific_selector_enabled�sG��)�:�� 
�7�7�8J�K�K�
F�!�[�%E�E�)� �(�(�!	)r�dom_infoc��|j�d�S)z|
        Get cPanel FPM service name
        :param dom_info: a DomainInfo object
        :return: FPM service name
        z-php-fpm)r:)rrZs  r�fpm_service_namezCPanelManager.fpm_service_name�s���,�6�6�6�6r)N)�__name__�
__module__�__qualname__�__doc__rr�	TypeErrorrrr*rr/�listrrIrrrP�boolrUrYr\r5rrrr!s���������
:�9�9�9�9�9�9�9�	�	�O�
��>���u�$�$�*O�O�J�'�*O�O�J�'�*O�O�J�'����
�
�
���
����.�H�.�.�.�.�4��4��#��4�4�4�4�.$(�+�+��+�D�+�,6�+�+�+�+�Z���3��:���� �����,
R��
R�QU�
R�
R�
R�
R�)�:�)�$�)�)�)�)�67��7��7�7�7�7�7�7s�1�9�9r)r`�json�os�
subprocess�collectionsr�pipesr�typingr�clcommon.lib.whmapi_librr�clcommon.utilsrr	�
xray.internalr
�internal.exceptionsrr
�internal.typesr�internal.user_plugin_utilsrr�baserrr5rr�<module>rqsK��������	�	�	�	����� � � � � � �������������>�>�>�>�>�>�>�>�?�?�?�?�?�?�?�?�'�'�'�'�'�'�E�E�E�E�E�E�E�E�'�'�'�'�'�'���������������l7�l7�l7�l7�l7�K�l7�l7�l7�l7�l7r

Zerion Mini Shell 1.0