9Mjz
& d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlmc mZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZmZmZ ddlm Z m!Z!m"Z" ddl#Z#dd l$m%Z% dd
l&m'Z' ddl(m)Z) ddl*m+Z+m,Z,m-Z-m.Z. dd
l/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z; ddlZ>m?Z?m@Z@mAZAmBZB ddlCmDZDmEZE ejF d ZGeHeIejJ fZKde de fdZLde de fdZMde de fdZNdeOfdZPdefdZQdeOdefdZRdeSfd ZTd!e!eU deSfd"ZVd!e!eU deSfd#ZWdeSfd$ZXe?fd%eSd&eSddfd'ZYe?fd&eSdeSfd(ZZdeSfd)ZZde"e[ fd*Z\eNdeSfd+ Z]d,eSde"eS fd-Z^de"eS fd.Z_d\d/Z`e@fd0eSde"eS fd1Za ejb d2 Zcd3eSddfd4Zdd3eSd5eedeefd6Zfd7eSd8eSddfd9Zgd:eSdd;fd<Zhd=eOdeOfd>Zid3eSde"ej fd?Zkd3eSde"eS fd@Zld]d3eSddfdAZmd3eSde[fdBZnde[fdCZode[fdDZpdEe[ddfdFZqde[fdGZrde[fdHZsde[fdIZtd,eSde[fdJZudK Zved^dN Zwed_dPeSdQe[fdR Zxed`dSeOddfdT Zye dadWeOdXeOdSeOddfdY ZzedZ Z{d[ Z|dS )bzB
This module contains helpful utility functions for X-Ray Manager
N)contextmanager)date timedeltawraps)glob)socketfromfdAF_UNIXSOCK_STREAM)CallableListOptional)AtexitIntegration)LoggingIntegration)Feature)is_panel_feature_supportedget_cp_description getCPNameis_wp2_environment)get_cl_edition_readable)UIConfig)drop_privileges)get_rhn_systemid_value)php_get_vhost_versions_user)gettext )
sentry_dsnlocal_tasks_storage
agent_file
logging_leveljwt_token_locationuser_agent_sock) XRayErrorXRayManagerExitutilsfuncreturnc F d t fd }|S )zf
Decorator aimed to update ini file in cagefs-skeleton
Applies to task.add nd task.remove
c t j | d j d }| d r8t d r)t j d|dd }n| d rt d rt j d |dd }t j t j | s1t j t j | ndS t j | st j | rt j
| r t d
d|i dS t j
| dS # t $ r7}t d
|t | d Y d}~dS d}~ww xY wdS t j
| r t dd|i dS t! |d 5 }| }ddd n# 1 swxY w Y t j |t j t j z t j z t j z d } t j || t j | dS # t j | w xY w# t $ r7}t d|t | d Y d}~dS d}~ww xY w)zd
Copy ini file to cagefs-skeleton
Action takes place for cPanel ea-php only
r zxray.iniz/opt/cpanelz/usr/share/cagefsz"/usr/share/cagefs/.cpanel.multiphpr Nz
/usr/localz/usr/share/cagefs-skeletonz-Refusing to unlink symlink in cagefs-skeletonxray_iniextraz'Failed to unlink ini in cagefs-skeleton)r+ errz0Refusing to copy over symlink in cagefs-skeletonrbi z'Failed to copy ini into cagefs-skeleton)ospathjoinini_location
startswithr existsdirnamemkdirlexistsislinkloggerwarningunlinkOSErrorstropenreadO_WRONLYO_CREATO_TRUNC
O_NOFOLLOWwriteclose)argsoriginal_iniskeleton_iniesrc src_bytesfds J/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/internal/utils.pyupdatezskeleton_update..updateJ s
w||DG$8*EE""=11 d#7% 7% 7<<(L(4QRR(8: :LL
$
$\
2
2 t,8. 8. 7<<(D(4QRR(8: :L7>>"'//,"?"?@@
866777Fw~~l++ 6w|,,
:7>>,// NN#R*4l)C # E E EF:Il+++++ : : :NN#L6B14Q*9 *9 # : : : : : : : : ::
:
:
67>>,// NN#U*4l)C # E E EF ,-- + #
I+ + + + + + + + + + + + + + +W\[2:5
BR]R"$ $!HR+++HRLLLLLBHRLLLL
6
6
6H2>-0VV&5 &5 6 6 6 6 6 6 6 6 6
6ss 3G
H
,HH
=L L J 4L JL JA
L K> (L >LL
M!,MMc " | i | | dS )
Wraps func
N )rG kwargsr' rO s rN wrapperz skeleton_update..wrapper s)
df
r )r' rT rO s ` @rN skeleton_updaterV D sK 36 36 36j 4[[ [ NrU c P d d t fd }|S )zs
Decorator aimed to update DBM storage with fake_id:real_id mapping
Applies to task.add nd task.remove
c | d }t t 5 }|j ||j <