Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/clselect/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clselect/__pycache__/clselectctl.cpython-311.pyc

�

m4�f�$��z�ddlmZddlmZddlmZddlZddlZddlZddlmZddl	Z	ddl
Z
ddlZddl
mZddlmZdd	lmZdd
lmZmZddlmZmZddlmZdd
lmZddlmZddlm Z ddl!m"Z"ddl
m#Z#mZgd�Z$edd��Z%edd��Z&d�Z'd�Z(d�Z)d�Z*d�Z+d#d�Z,d�Z-d#d�Z.d�Z/d �Z0d!�Z1d"�Z2dS)$�)�absolute_import)�print_function)�divisionN)�
namedtuple)�List)�	iteritems�)�clpassenger)�cpusers�	getCPName)�drop_privileges�ClPwd)�is_no_php_binaries_on_cpanel)�ClSelectExcept)�NodeManager)�
PythonManager)�get_abs_rel)�Optionalr)�public_html�rubyvenv�
virtualenvz.cl.selectorz.cagefs�www�nodevenv�ApplicationSummary��user�version�doc_root�interpreter�
app_status�InterpreterSummary�r�version_full�enabled�	installedc�@�d|vrtd���tj�|��rtd���|ddkrtd���|tvrtd|z���tjd|��}|�td	���dS)
N� z#Directory should not contain spacesz+Directory should be relative to user's home����/z-Directory should not contain a trailing slashzDirectory "%s" not allowedz[-\.\w\/]+$z*Directory name contains invalid characters)�
ValueError�os�path�isabs�DISABLED_DIRECTORY_NAMES�re�match)�	directory�	all_valids  �K/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/clselectctl.py�check_directoryr4&s���
�i����>�?�?�?�	�w�}�}�Y���I��G�H�H�H���}�����H�I�I�I��,�,�,��5�	�A�B�B�B�����3�3�I����E�F�F�F���c�h�dD]}||vrtd����|dvrd}|�d��S)N)�#�?z./zAlias is not valid)�.�r))r*�strip)�alias�cs  r3�	get_aliasr>4sR��
�3�3����:�:��1�2�2�2��
�	������;�;�s���r5c�V�|�dd���dd��S)N�_r)z//��replace)�prefixs r3�
get_directoryrD?s&���>�>�#�s�#�#�+�+�D�#�6�6�6r5c�V�|�dd���dd��S)Nr@�__r)rA)r1s r3�
get_prefixrGCs(�����S�$�'�'�/�/��S�9�9�9r5c��|s,tj��}tj|��j}|dkrtd���|S)N�rootz8User parameter must be specified if current user is root)r+�geteuid�pwd�getpwuid�pw_namer*)r�current_euids  r3�get_userrOGsD���2��z�|�|���|�L�)�)�1���v�~�~��S�T�T�T��Kr5c���|dvrtj�|��Stj�|��otj�|��S)z�
    Application is valid only if binary and app_root exists
    :param binary_path: path to binary in virtual environment
    :param app_root: path to root directory of application
    :return: result of checking
    :rtype: bool
    ��nodejs�python)r+r,�isdir�isfile)r�app_root�binary_paths   r3�_verify_applicationrXPsK���*�*�*��w�}�}�X�&�&�&�
�7�>�>�+�&�&�B�2�7�=�=��+B�+B�Br5c���d}g}tj��}t��D�]:}	tj��r@ddlm}||d���f}ttdtd�|������}t|��5tj|��|�
t|||����ddd��n#1swxYwY��#tj$rY��t"$rht%jt(��}|�d||t-j��t1t-j����fz��Y��8wxYw|S)z8Find and return all apps for given interpreter on serverNr)�userdomainsT)�as_rootc��|r|dndS)Nr�)�xs r3�<lambda>z-server_applications_summary.<locals>.<lambda>ps��a�&9�a��d�d�T�r5z]DEBUG: user %s present in panel but doesn't exist in system. Process euid=%d. Trace: %s at %s)r+rJr�detect�is_da�"clcommon.cpapi.plugins.directadminrZ�list�filter�mapr
rK�getpwnam�extend� _user_applications_short_summaryr�NoSuchUserException�KeyError�logging�	getLogger�__name__�error�	traceback�
format_exc�str�
extract_stack)r�domains_data�applications�euidrrZ�domains_list�loggers        r3�server_applications_summaryrx]s����L��L�
�:�<�<�D��	�	�_�_��	_��|�~�~�
�J�J�J�J�J�J�*�{�4��>�>�>�?��#����9�9�(����� � ��!��&�&�
W�
W���T�"�"�"��#�#�4�T�;��U�U�W�W�W�
W�
W�
W�
W�
W�
W�
W�
W�
W�
W�
W����
W�
W�
W�
W���
�(�	�	�	��H��	_�	_�	_��&�x�0�0�F��L�L�x���i�&:�&<�&<�c�)�BY�B[�B[�>\�>\�]�^�
_�
_�
_�
_�
_�	_�����s=�A"C�9C�C�C	�C�C	�C�E�.A-E�Ec	#�BK�|}|dvr�	|dkrddlm}nddlm}|���|��}n#tj$rYdSwxYwt
|��D]j\}}	t||��\}}	n#tj$rY�+wxYwt||��r+t||d|z|d||d�	��V��kdSt
tj||�
����D]�\}
}|d|kr�|d|d
}}t|||��r{tj
�tj
�tj
�|������}t|||d|dd�	��V���dS)a�
    Return generator with all applications for given user and interpreter.
    To increase performance, only a small part of the
    information about the applications is given.
    :param user: name of panel user
    :param interpreter: name of interpreter (python, ruby, etc)
    :param domains_docroots_data: total data about users domains
    :return: Generator[ApplicationSummary]
    rQrRr	)�ApplicationsManagerNz
%s_version�domainr r)�userdomains_datar�binaryr1�docroot�started)�clselectnodejs.apps_managerrz�clselectpython.apps_manager�get_user_config_datar�	WrongDatarrrXrr
�summaryr+r,�basename�dirname)
rr�domains_docroots_datar|rz�config_data�app�datarVr@�dummyr}�
it_versions
             r3rhrh�s5����-���*�*�*�	��h�&�&�L�L�L�L�L�L�L�L�L�L�L�L�L�-�-�/�/�D�D�T�J�J�K�K���'�	�	�	��F�F�	����"�;�/�/�	�	�I�C��
�)�$��4�4���!�!��!�+�
�
�
���
����"�;��9�9�
�(�� ���!;�<�!�(�^� +�#�L�1��������
	�	�%�[�%8��P`�%a�%a�%a�b�b�		`�		`�K�E�4��M�"�k�1�1�� $�H�~�t�K�/@�H�F�"�;��&�A�A�
`��W�-�-�b�g�o�o�b�g�o�o�f�>U�>U�.V�.V�W�W�
�(�d�J�QU�V_�Q`�59�-�5H�U^�`�`�`�`�`�`��		`�		`s!�0;�A�
A�&A:�:B�Bc�j�|dkrt��jS|dkrt��jSdS)z-Return default version for given interpreter rRrSN)r�default_versionr)rs r3�get_default_versionr��s7���h����}�}�,�,��h������.�.��4r5c#�K�|dkr#t���d���}n7|dkr#t���d���}nt���t	|d��D]�\}}|ddk}|dkr6tt
|�d��d	����}n0d�|�d��d
d���}t|||d���V���d
S)
z.Return generator for interpreters all versionsrRT)�installed_interpreters_onlyrS�available_versions�statusr$r9rN�r")
r�get_summaryr�NotImplementedErrorrrq�int�split�joinr!)r�interpretersr�version_infor$�
major_versions      r3�_iter_interpretersr��s�����h���"�}�}�0�0�T�0�R�R���	��	 �	 �$���2�2�t�2�T�T���!�#�#�#�!*�<�8L�+M�!N�!N�o�o�����x�(�I�5���(�"�"���G�M�M�#�$6�$6�q�$9� :� :�;�;�M�M� �H�H�W�]�]�3�%7�%7����%;�<�<�M� ��W�V]�im�n�n�n�n�n�n�n�o�or5c	#�K�ddlm}|��}|���}|D].\}}}t||d|�|�����V��/dS)zf
    Return generator with all PHP versions on server.
    :return: Generator[InterpreterSummary]
    r	)�ClSelectT�r%r$N)�clselectr��list_alternativesr!�is_version_enabled)r��php�versionsr�full_versionr@s      r3�_iter_php_interpretersr��s�����
#�"�"�"�"�"�
�(�*�*�C��$�$�&�&�H�$,�5�5� ���q� ��\�T��*�*�7�3�3�5�5�5�	5�	5�	5�	5�5�5r5c	�r�|dkr=t��dkrt��rgStt����S|dkrddlm}n'|dvrtt
|����St�g}|��D]2}|�t|j
|jdd������3|S)	z<Find and return all versions for given interpreter on serverr��cPanel�rubyr	)r�)rSrRTr�)rrrcr��clselectruby.interpretersr�r�r��appendr!rr#)rr��it_list�its    r3�"interpreter_versions_short_summaryr��s����e����;�;�(�"�"�'C�'E�'E�"��I��*�,�,�-�-�-�	��	�	�;�;�;�;�;�;�;�	�,�	,�	,��&�{�3�3�4�4�4�!�!��G��l�n�n�f�f�����)�"�*�b�o�QU�_c�d�d�d�e�e�e�e��Nr5)N)3�
__future__rrrr+rKr/�collectionsrrkro�cldetectlibr`�typingr�future.utilsrr:r
�clcommon.cpapirr�clcommon.clpwdr
r�clcommon.cpapi.plugins.cpanelr�clselectexceptr�clselectnodejs.node_managerr�clselectpython.python_managerr�utilsrrr.rr!r4r>rDrGrOrXrxrhr�r�r�r�r]r5r3�<module>r�so��'�&�&�&�&�&�%�%�%�%�%�%�������	�	�	�	�
�
�
�
�	�	�	�	�"�"�"�"�"�"�������������������"�"�"�"�"�"�������-�-�-�-�-�-�-�-�1�1�1�1�1�1�1�1�F�F�F�F�F�F�*�*�*�*�*�*�4�4�4�4�4�4�8�8�8�8�8�8�������!�!�!�!�!�!�!�!�r�r�r���Z� 4�6r�s�s���Z� 4�6i�j�j��G�G�G����7�7�7�:�:�:����
C�
C�
C�
C�'�'�'�T.`�.`�.`�.`�b���o�o�o�&5�5�5�����r5

Hacked By AnonymousFox1.0, Coded By AnonymousFox