HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clselect/__pycache__/clselectctl.cpython-37.pyc
B

���^�#�@s~ddlmZddlmZddlmZddlZddlZddlZddlmZddl	Z	ddl
Z
ddlZddl
mZddlmZdd	lmZdd
lmZmZddlmZmZddlmZdd
lmZddlmZddlm Z ddl!m"Z"ddl
m#Z#mZdddddddgZ$edd�Z%edd�Z&dd�Z'dd �Z(d!d"�Z)d#d$�Z*d%d&�Z+d5d'd(�Z,d)d*�Z-d6d+d,�Z.d-d.�Z/d/d0�Z0d1d2�Z1d3d4�Z2dS)7�)�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)�OptionalrZpublic_htmlZrubyvenvZ
virtualenvz.cl.selectorz.cagefsZwww�nodevenv�ApplicationSummary)�user�version�doc_root�interpreter�
app_status�InterpreterSummary)r�version_full�enabled�	installedcCsld|krtd��tj�|�r$td��|ddkr8td��|tkrLtd|��t�d|�}|dkrhtd	��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)�	directoryZ	all_valid�r*�E/opt/alt/python37/lib/python3.7/site-packages/clselect/clselectctl.py�check_directory&sr,cCs4xdD]}||krtd��qW|dkr*d}|�d�S)N)�#�?z./zAlias is not valid)�.�r!)r"�strip)�alias�cr*r*r+�	get_alias4s
r4cCs|�dd��dd�S)N�_r!z//)�replace)�prefixr*r*r+�
get_directory?sr8cCs|�dd��dd�S)Nr5�__r!)r6)r)r*r*r+�
get_prefixCsr:cCs,|st��}t�|�j}|dkr(td��|S)N�rootz8User parameter must be specified if current user is root)r#�geteuid�pwd�getpwuid�pw_namer")r�current_euidr*r*r+�get_userGsrAcCs,|dkrtj�|�Stj�|�o*tj�|�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_rootZbinary_pathr*r*r+�_verify_applicationPsrGc
Cs�t��rddlm}|�}nd}g}t��}x�t�D]�}y4t|��"t�	|�|�
t|||��WdQRXWq4tj
k
r�w4Yq4tk
r�t�t�}|�d||t��tt���f�Yq4Xq4W|S)z8Find and return all apps for given interpreter on serverr)�$_get_domains_docroots_from_da_binaryNz]DEBUG: user %s present in panel but doesn't exist in system. Process euid=%d. Trace: %s at %s)�detectZis_daZ"clcommon.cpapi.plugins.directadminrHr#r<r
rr=�getpwnam�extend� _user_applications_short_summaryr
�NoSuchUserException�KeyError�logging�	getLogger�__name__�error�	traceback�
format_exc�str�
extract_stack)rrH�domains_docroots_dataZapplications�euidr�loggerr*r*r+�server_applications_summary]s&


&rZc
	csz|dk	r"||kr"t||���}nd}|dkr�y2|dkrFddlm}nddlm}|��|�}Wntjk
rvdSXx�t|�D]b\}}yt	||�\}}	Wntjk
r�w�YnXt
||�r�t||d||d||dd	�Vq�Wn�x�ttj
||d
��D]t\}
}|d|k�r�q�|d|d
}}t
|||��r�tj�tj�tj�|���}t|||d|ddd	�V�q�WdS)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]
    N)rBrCrBr)�ApplicationsManagerz
%s_version�domainr)rrrrr)�userdomains_datar�binaryr)�docroot�started)�list�items�clselectnodejs.apps_managerr[Zclselectpython.apps_manager�get_user_config_datar�	WrongDatarrrGrr	�summaryr#r$�basename�dirname)
rrrWr]r[Zconfig_dataZapp�datarFr5�dummyr^Z
it_versionr*r*r+rL~s>

rLcCs$|dkrt�jS|dkr t�jSdS)z-Return default version for given interpreter rBrCN)r�default_versionr)rr*r*r+�get_default_version�s
rlccs�|dkrt�jdd�}n|dkr0t�jdd�}nt��xnt|d�D]^\}}|ddk}|dkrxtt|�d�d	��}nd�|�d�d
d��}t	|||dd�VqDWd
S)
z.Return generator for interpreters all versionsrBT)Zinstalled_interpreters_onlyrCZavailable_versions�statusrr/rN�)rrrr)
r�get_summaryr�NotImplementedErrorrrU�int�split�joinr)r�interpretersr�version_inforZ
major_versionr*r*r+�_iter_interpreters�srvccsJddlm}|�}|��}x*|D]"\}}}t||d|�|�d�Vq WdS)zf
    Return generator with all PHP versions on server.
    :return: Generator[InterpreterSummary]
    r)�ClSelectT)rrN)�clselectrw�list_alternativesr�is_version_enabled)rw�php�versionsrZfull_versionr5r*r*r+�_iter_php_interpreters�sr}c	Cs�|dkr&t�dkrt�rdStt��S|dkr<ddlm}n|dkrPtt|��St�g}x(|�D]}|�t	|j
|jddd	��q`W|S)
z<Find and return all versions for given interpreter on serverr{�cPanelN�rubyr)rt)rCrBT)rr)rrrar}Zclselectruby.interpretersrtrvrp�appendrrr)rrtZit_list�itr*r*r+�"interpreter_versions_short_summary�s
r�)N)N)3�
__future__rrrr#r=r'�collectionsrrOrSZcldetectlibrI�typingr�future.utilsrr0r	�clcommon.cpapir
r�clcommon.clpwdrr
Zclcommon.cpapi.plugins.cpanelr�clselectexceptrZclselectnodejs.node_managerrZclselectpython.python_managerr�utilsrrr&rrr,r4r8r:rArGrZrLrlrvr}r�r*r*r*r+�<module>sF

	

!
4