File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/__pycache__/wpos_admin.cpython-311.pyc
�
t5:f�� �
�" � d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl
Z
d dlZd dlm
Z
d dlmZ d dlmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZmZmZmZm Z d d l!m"Z" d d
l#m$Z$ d dl%m&Z&m'Z' d dl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 d d
l1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZE d dlFmGZG d dlHmIZI d dlJmKZK d dlLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[ d dl\m]Z] d dl^m_Z`maZa d dlbmcZcmdZd d dlemfZfmgZgmhZh d dlimjZj d dlkmlZlmmZm d dlnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZm�Z�m�Z�m�Z� d dl�m�Z�m�Z�m�Z�m�Z� d dl�m�Z�m�Z�m�Z� d dl�m�Z�m�Z� d dl�m�Z� d dl�m�Z� d dl�m�Z� d d l�m�Z�m�Z�m�Z� e`d!� � Z� e`d"� � Z� ecd#d$edd%�&� � Z� efe�� � Z� G d'� d(e�� � Z�d)e�d*e�d+ee�e)f d,ee�e)f fd-�Z�d.� Z�d)e�d*e�d/ee� d0ee� fd1�Z�d)e�d2eee�e�e�f fd3�Z�dS )4� )�absolute_importN)�deepcopy)�asdict)�Dict�Iterator�Set�Tuple�List�Optional)�Enum)�
pid_exists)�cpusers�userdomains�is_admin�cpinfo� getCPName)�get_or_create_unique_identifier��migrate_configs)�install_cron_files�clean_clwpos_crons)�
FeatureStatus�FeatureStatusEnum�AdminSuitesConfig�any_suite_visible_on_server�is_module_visible_for_user�StatusSource�extract_suites�is_suite_visible_for_user)�ALL_OPTIMIZATION_FEATURES�OBJECT_CACHE_FEATURE�CDN_FEATURE�enable_without_config_affecting� disable_without_config_affecting�DocRootPath�SITE_OPTIMIZATION_FEATURE�Feature)�
ALL_SUITES�any_suite_allowed_on_server�get_suites_allowed_path�get_admin_suites_config�write_suites_allowed�extract_features�is_module_allowed_for_user�PremiumSuite�CDNSuitePro�CDNSuite�AWPSuite)�drop_privileges)� WposError)�
UserConfig)�ALT_PHP_REDIS_ENABLE_UTILITY�CLWPOS_UIDS_PATH�PHP_REDIS_ENABLE_UTILITY�SUITES_MARKERS�MIGRATION_NEEDED_MARKER�
SCAN_CACHE�ADMIN_ENABLE_FEATURE_STATUS�ADMIN_ENABLE_FEATURE_PID�$ADMIN_UPDATE_OBJECT_CACHE_BANNER_PID�USERS_PLUGINS_SYNCING_PID�CLN_URL�SMART_ADVICE_ROOT_UTILITY�ON_OFF_IDENTIFIERS�XRAY_MANAGER_UTILITY�CLWPOS_WHMCS_STATS_FILE)�reload_redis)�gettext�billing)�ArgumentParser�CustomFormatter)�
setup_logging�init_wpos_sentry_safely�ADMIN_LOGFILE_PATH)� NoPackage)�ReportGenerator�ReportGeneratorError)�catch_error�error_and_exit�
print_data�check_license_decorator�set_wpos_icon_visibility�acquire_lock�write_public_options�get_pw�is_redis_configuration_running�install_monitoring_daemon�get_server_wide_options�is_ui_icon_hidden�ServerWideOptions�daemon_communicate�ExtendedJSONEncoder�is_shared_pro_safely�get_supported_suites�jwt_token_check�should_xray_user_agent_enabled�should_xray_user_agent_disabled)�get_backup_folders�backup_accelerate_wp�+restore_accelerate_wp_public_options_backup�%make_accelerate_wp_backups_deprecated)�install_panel_hooks�"install_yum_universal_hook_alt_php�_uninstall_hooks)�setup_mount_dir_cagefs�_remount_cagefs��fill_current_wpos_statistics)�has_wps)�
disable_quota)�configure_accelerate_wp�configure_accelerate_wp_premium�configure_accelerate_wp_cdnz{Unable to run CL AccelerateWP daemon. Caching databases won't start and work. You can find detailed information in log filez�Configuration of PHP redis extension is running in background process. This may take up to several minutes. Until the end of this process functionality of CL AccelerateWP is limited.z/usr/bin/clwpos-adminz3Utility for control CL AccelerateWP admin interfaceF)�formatter_class�allow_abbrevc �� � e Zd ZdZ G d� de� � Zd� Zed� � � Zd� Z e
d� � � Ze
d� � � Ze
d � � � Z
e� � � d
efd�� � Zee� dd
�� � e� ddd�� � e� � � ed
efd�� � � � � � � � � � Zee� ddd�� � e� � � ed� � � � � � � � � Zee� � � ed
efd�� � � � � � Zee� � � ed
efd�� � � � � � Ze
dDd�� � Zed
efd�� � Zd� Zdee fd �Zd!� Zed
efd"�� � Zd#� Z d$� Z!eed%� � � � � Z"ed
efd&�� � Z#d
efd'�Z$ed
efd(�� � Z%ed)� � � Z&d*� Z'd+� Z(d,� Z)d-� Z*d.� Z+ee� � � d/� � � � � Z,ee� � � dEd
efd0�� � � � Z-ee� � � d1� � � � � Z.ee� � � d2� � � � � Z/e
d3e0d4e1d
e2fd5�� � Z3d6� Z4d7ed8ee d9e5d:e6d;e7j8 d<e9d=e2d>e2d
e:e2e;e f fd?�Z<d@� Z=dA� Z>dBe2fdC�Z?dS )F�CloudlinuxWposAdminz6
Class for run cloudlinux-wpos-admin commands
c � � e Zd ZdZdZdZdZdS )�"CloudlinuxWposAdmin.EnablingStatuszH
Basic statuses while feature is enabling in background
�idle�progress�doneN)�__name__�
__module__�__qualname__�__doc__�IDLE�PROGRESS�DONE� � �H/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/wpos_admin.py�EnablingStatusry � s) � � � � � � � � �������r� r� c �F � d| _ | t t � � | _ t | j � � d| _ d| _ t t j �
d� � � � | _ | j rt j
| _ d S t j | _ d S )NFz/var/clwposzmodules_allowed.json�CL_WPOS_WAIT_CHILD_PROCESS)�_is_jsonrJ r} �_loggerrK �clwpos_path�modules_allowed_name�bool�os�environ�get�wait_child_process�
subprocess�run� exec_func�Popen��selfs r� �__init__zCloudlinuxWposAdmin.__init__� s� � ���
��&�$�X�.�.������-�-�-�(���$:��!�"&�r�z�~�~�6R�'S�'S�"T�"T����"� .�'�^�D�N�N�N�'�-�D�N�N�Nr� c �� � | � |� � | _ d| _ t | | j j � dd� � � � � � }t
| j |� � dS )zs
Run command action
:param argv: sys.argv[1:]
:return: clwpos-user utility retcode
T�-�_N)�_parse_args�_optsr� �getattr�command�replacerR )r� �argv�results r� r� zCloudlinuxWposAdmin.run� sd � � �&�&�t�,�,��
���
�D���t�z�1�9�9�#�s�C�C�D�D�F�F���4�=�&�)�)�)�)�)r� c � � t ��N)�NotImplementedError)r� r� s r� r� zCloudlinuxWposAdmin._parse_args� s � �!�!r� c � � | D ]{}t j |� � ret j � t j |� � � � s4t t j |� � d� � � � � �|d S )N�w)r9 r� r� �path�isfile�open�close��suites_list�suites r� �_create_markersz#CloudlinuxWposAdmin._create_markers� sw � � � =� =�E��!�%�(�(�
=������@R�SX�@Y�@Y�1Z�1Z�
=��^�'��.�.��4�4�:�:�<�<�<�� =� =r� c �� � | D ]m}t j |� � rWt j � t j |� � � � r&t j t j |� � � � �nd S r� )r9 r� r� r� r� �unlinkr� s r� �_clear_markersz"CloudlinuxWposAdmin._clear_markers� so � � � 5� 5�E��!�%�(�(�
5�R�W�^�^�"�&�u�-�-�./� ./�
5�� �.�,�U�3�3�4�4�4�� 5� 5r� c � � | dk S )N�onr� )�opts r� �_is_truezCloudlinuxWposAdmin._is_true� s � ��d�{�r� �returnc �< � t � � }nT# t t t t f$ r4}| j � dt |� � � � i cY d}~S d}~ww xY w|D ]�}t |� � }t |� � 5 t |� � D ]k\ }}}t |t j
� t j |� � j |� � � � }t% t'