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__/plesk.cpython-311.pyc

�

��f����dZddlZddlZddlmcmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZdd
lmZmZGd�de��ZdS)
zM
This module contains classes implementing X-Ray Manager behaviour
for Plesk
�N)�ChainMap)�
phpinfo_utils�)�BaseManager�)�XRayManagerError�XRayMissingDomain)�
DomainInfo)�user_mode_verification�with_fpm_reload_restrictedc
��eZdZdZdddddddd	d
ddd
d�Zdefd�Zeede	de
fd�����Zede
fd���Zde
defd�Zde
de	fd�ZdS)�PleskManagerzA
    Class implementing an X-Ray manager behaviour for Plesk
    z/opt/plesk/php/5.4/etc/php.dz/opt/plesk/php/5.5/etc/php.dz/opt/plesk/php/5.6/etc/php.dz/opt/plesk/php/7.0/etc/php.dz/opt/plesk/php/7.1/etc/php.dz/opt/plesk/php/7.2/etc/php.dz/opt/plesk/php/7.3/etc/php.dz/opt/plesk/php/7.4/etc/php.dz/opt/plesk/php/8.0/etc/php.dz/opt/plesk/php/8.1/etc/php.dz/opt/plesk/php/8.2/etc/php.dz/opt/plesk/php/8.3/etc/php.d)zplesk-php54zplesk-php55zplesk-php56zplesk-php70zplesk-php71zplesk-php72zplesk-php73zplesk-php74zplesk-php80zplesk-php81zplesk-php82zplesk-php83�returnc�6�t|j|j��S)z�
        Get supported PHP versions
        :return: a chained map with basic supported versions
                and Plesk supported versions
        )r�VERSIONS�VERSIONS_Plesk)�selfs �I/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/manager/plesk.py�supported_versionszPleskManager.supported_versions1s ����
��+�-�-�	-��domain_namec	����d�}t�fd�|���D��d��}|�-|j�dd�i���t	����|\}}}|j�d�||��|jrItj|����}t�|�
d	��|jd
||j|���St�||��|d|v|�
��S)z�
        Retrieve information about given domain from control panel environment:
        PHP version, user of domain, fpm status
        :param domain_name: name of domain
        :return: a DomainInfo object
        c��d|vrd}nSd|vrd|�d��d��}n0d�|�d��dd���}|S)	z�
            Resolve version for lsphp handlers
            :param h: original Plesk php handler id
            :return: resolved alt-php* version
            zlsphp-customz	alt-php56�lsphpzalt-php�-���Nr)�split�join)�h�vers  r�resolve_lsphp_versionz;PleskManager.get_domain_info.<locals>.resolve_lsphp_versionDsf����"�"�!����A���2�������R� 0�2�2����h�h�q�w�w�s�|�|�B�Q�B�/�0�0���Jrc3�4�K�|]}|d�k�|V��dS)rN�)�.0�itemrs  �r�	<genexpr>z/PleskManager.get_domain_info.<locals>.<genexpr>Rs=�����4�4�T� ��G�{�2�2�!�2�2�2�2�4�4rNz#Domain does not exist on the serverr)�extraz@Retrieved domain info: domain %s owned by %s uses php version %s)�domainz	plesk-phpT)�name�panel_php_version�php_ini_scan_dir�is_selector_applied�user�	panel_fpm�handler�fpm)r)r*r-r.r/)
�next�query_db�logger�warningr	�info�phpinfo_moder�get_php_configurationr
�get_full_php_version�absolute_ini_scan_dir�
is_php_fpm)rrr!�domain_datar(r-r/�configs `      r�get_domain_infozPleskManager.get_domain_info:sg���	�	�	��4�4�4�4�T�]�]�_�_�4�4�4�59�;�;�����K��� E�'4�k�&B�
 �
D�
D�
D�#�K�0�0�0� +����g�����N���w�	(�	(�	(���	!�"�8��[�*�*�*�F�� �"(�"=�"=�k�"J�"J�!'�!=�%)�� �+��
!�
!�
!�

!�� �"7�"7��"@�"@���7�*��!�!�!�
!rc#�"K�d�}d}tjdd|dgdd|�����}	tjd�|j����}|�d	��D]W}|�d
��j}|�d��j}|�d��j}|||fV��XdS#tj	$r7}ttd
��t|j��z��|�d}~wwxYw)z�
        Query Plesk database through plesk db utility
        and yeild parsed xml result
        :return: tuple(domain_name, domain_user, domain_handler)
        c�R�dtj�dd��vrddiSdS)a
            plesk db utility needs to be able to find mysql executable,
            which resides in /usr/bin.
            If we do not have it in PATH, the error will be thrown:
            'exec: "mysql": executable file not found in $PATH'
            z/usr/bin�PATH�N)�os�environ�getr#rr�check_path_envz-PleskManager.query_db.<locals>.check_path_env|s/���������!;�!;�;�;��
�+�+��trz�select d.name,s.login,h.php_handler_id from (select id, name from domains union select dom_id, name from domain_aliases) d join hosting h on d.id=h.dom_id join sys_users s on h.sys_user_id=s.idz/usr/sbin/plesk�dbz--xmlT)�capture_output�text�envrA�rowz./field[@name='name']z./field[@name='login']z./field[@name='php_handler_id']z,Failed to parse XML from plesk db output: %sN)
�
subprocess�run�ET�
fromstringr�stdout�iter�findrH�
ParseErrorr�_�str)	rE�query�result�rootrJr�	user_namer/�es	         rr2zPleskManager.query_dbtsM����
	�
	�
	�X����!2�!%�!&�!(�!*�04�$�$2�N�$4�$4�6�6�6��		_��=������!7�!7�8�8�D��y�y��'�'�
6�
6��!�h�h�'>�?�?�D���H�H�%=�>�>�C�	��(�(�#D�E�E�J��!�9�g�5�5�5�5�5�	
6�
6��
�}�	_�	_�	_�"��@�A�A�C��
�DV�DV�V�X�X�]^�
_�����	_���s�BC�D�2D	�	D�domain_infoc�V���fd�}d�jvrd�jvp	|��S�jS)z�
        Check if selector is enabled specifically for Plesk panel
        :param domain_info: a DomainInfo object
        :return: True if yes, False otherwise
        c�B���jr�jdd��jvSdS)z�
            Checks if php selector and cloudlinux selector have
            the same php version.
            :param domain_info: a DomainInfo object
            :return: digits as string or None
            ���NF)�selector_php_versionr/)rZs�r�same_php_in_both_selectorszPPleskManager.panel_specific_selector_enabled.<locals>.same_php_in_both_selectors�s7����/�
3�"�7��s�s��*�2�3�3��5rr�custom)r/r.)rrZr_s ` r�panel_specific_selector_enabledz,PleskManager.panel_specific_selector_enabled�sY���
	�
	�
	�
	�
	��k�)�)�)��� 3�3�1�.�.�0�0�
2��(�(�(r�dom_infoc��|jS)z{
        Get Plesk FPM service name
        :param dom_info: a DomainInfo object
        :return: FPM service name
        )r/)rrbs  r�fpm_service_namezPleskManager.fpm_service_name�s
����rN)�__name__�
__module__�__qualname__�__doc__rrrrrrTr
r=�staticmethod�tupler2�boolrardr#rrrrs��������
6�5�5�5�5�5�5�5�5�5�5�5�
�
�N�-�H�-�-�-�-���6!�3�6!�:�6!�6!�6!� ����6!�p�#_�e�#_�#_�#_��\�#_�J)�:�)�$�)�)�)�)�0 �� �� � � � � � rr)rhrBrK�xml.etree.ElementTree�etree�ElementTreerM�collectionsr�
xray.internalr�baser�internal.exceptionsrr	�internal.typesr
�internal.user_plugin_utilsrrrr#rr�<module>rus����

�	�	�	�����"�"�"�"�"�"�"�"�"� � � � � � �'�'�'�'�'�'�������E�E�E�E�E�E�E�E�'�'�'�'�'�'���������[ �[ �[ �[ �[ �;�[ �[ �[ �[ �[ r

Zerion Mini Shell 1.0