File: //opt/cloudlinux/venv/lib/python3.11/site-packages/xray/internal/__pycache__/utils.cpython-311.pyc
�
�B�i;s �
�B � d Z ddlZddlZddlZddlZddlmZ ddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmc mZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZmZmZm Z m!Z!m"Z" dd l#m$Z$m%Z%m&Z& ddl'Z'dd
l(m)Z) ddl*m+Z+ ddl,m-Z- dd
l.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@ZA ddlBmCZCmDZDmEZEmFZFmGZGmHZH ddlImJZJmKZK ejL d� � ZMeNeOe
jP fZQde$de$fd�ZRde$de$fd�ZSde$de$fd�ZTdeUfd�ZVdefd�ZWd eUdefd!�ZXdeYfd"�ZZd#e%e[ deYfd$�Z\d#e%e[ deYfd%�Z]deYfd&�Z^eEfd'eYd(eYddfd)�Z_eEfd(eYdeYfd*�Z`deYfd+�Z`de&ea fd,�ZbeTdeYfd-�� � Zcd.eYde&eY fd/�Zdde&eY fd0�Zed^d1�ZfeFfd2eYde&eY fd3�Zg ejh d4� � Zid5eYddfd6�Zjd5eYd7ekdekfd8�Zld9eYd:eYddfd;�Zmd<eYdd=fd>�Znd?eUdeUfd@�Zod5eYde&ep fdA�Zqd5eYde&eY fdB�Zrd_d5eYddfdC�Zsd5eYdeafdD�ZtdeafdE�ZudeafdF�ZvdGeaddfdH�ZwdeafdI�ZxdeafdJ�ZydeafdK�Zzd.eYdeafdL�Z{dM� Z|ed`dP�� � Z}edadReYdSeafdT�� � Z~edbdUeUddfdV�� � Ze dcdYeUdZeUdUeUddfd[�� � Z�ed\� � � Z�d]� Z�dS )dzB
This module contains helpful utility functions for X-Ray Manager
� N)�getuser)�contextmanager)�date� timedelta��wraps)�glob)�socket�fromfd�AF_UNIX�SOCK_STREAM�
SOCK_DGRAM�AF_INET�AF_INET6)�Callable�List�Optional)�AtexitIntegration)�LoggingIntegration)�Feature)�is_panel_feature_supported�get_cp_description� getCPName�is_wp2_environment)�get_cl_edition_readable)�UIConfig)�drop_privileges)�get_rhn_systemid_value)�get_hostname)�php_get_vhost_versions_user)�gettext� )�
sentry_dsn�local_tasks_storage�
agent_file�
logging_level�jwt_token_location�user_agent_sock)� XRayError�XRayManagerExit�utils�func�returnc �F � �� d� �t � � � � �fd�� � }|S )zf
Decorator aimed to update ini file in cagefs-skeleton
Applies to task.add nd task.remove
c �X � t j � | d j d� � }|� d� � r8t d� � r)t j � d|dd� � � }n�|� d� � r�t d � � r�t j � d |dd� � � }t j � t j � |� � � � s1t j t j � |� � � � ndS t j � |� � s|t j � |� � r[ t j |� � dS # t $ r7}t � d
|t |� � d��� � Y d}~dS d}~ww xY wdS t j ||� � dS # 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"