Revonzy Mini Shell
Revonzy Mini Shell
�
�`�H"�V�� �$ � d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl m
Z
ddlmZm
Z
ddlmZ ddlmZ ddlmZmZ ddlmZ ddlZdd lmZ ddlZddlZddlZdd
lmZ ddlm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z' dd
l(m)Z) ddl*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ ddlAmBZBmCZCmDZDmEZE ddlFmGZG ddlHmIZI ddlJmKZKmLZL ddlMmNZN ddlOmPZPmQZQ ddlRmSZS ddlTZTdZU ede&jV z � � ZWdZX ejY eZ� � Z[ eLeK� � � e[j\ � � Z] G d!� d"� � Z^ed#� � � Z_d$� Z`d%� Zad&� Zbd'� Zcd(� Zdd)ee4eeeef fd*�Zfd+e4fd,�Zgd-� Zhd.� Zid/eed)dfd0�Zjd1� Zkd2� Zld3� Zmd4� ZndS )5u
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Copyright © 2019 Cloud Linux Software Inc.
This software is also available under ImunifyAV commercial license,
see <https://www.imunify360.com/legal/eula>
� N)�ThreadPoolExecutor)�contextmanager�suppress)�partial)�Path)�CalledProcessError�check_output)�Tuple)�
AlreadyLocked)�files)�health�
inactivity)�ConfigsValidator�Core�Merger�Model� SimpleRpc)� HookEvent)�
LicenseCLN)�MessageSink�
MessageSource)�g)�IndependentAgentIDAPI)�TheSink)�instance�simplification� tls_check)�NonRootRpcServer�NonRootRpcServerAV� RpcServer�RpcServerAV�
is_running)�systemd_notifier)�Task�create_task_and_log_exceptions�is_root_user�is_systemd_boot)�is_db_corrupted)�EXITCODE_GENERAL_ERROR)�DAY�
rate_limit)�flush_sentry)�MalwareHitStatus�MalwareScanResourceType)�
MalwareHiti4 z%s.is_corruptedz�Imunify360 database is corrupt. Application cannot run with corrupt database. Please, contact Imunify360 support team at https://cloudlinux.zendesk.com)�periodc � � e Zd Zd� Zd� ZdS )�TaskFactoryc �, � t � � | _ d S �N)�set�pool)�selfs �@/opt/imunify360/venv/lib/python3.11/site-packages/imav/server.py�__init__zTaskFactory.__init__d s � ��E�E�� � � � c � � t ||�� � }| j � |� � |� | j j � � |S )N��loop)r$ r6 �add�add_done_callback�discard)r7 r= �coro�tasks r8 �__call__zTaskFactory.__call__g sF � ��D�t�$�$�$��� �
�
�d�������t�y�0�1�1�1��r: N)�__name__�
__module__�__qualname__r9 rC � r: r8 r2 r2 c s2 � � � � � �� � �� � � � r: r2 c # � K � dV � dS # t $ r;}t � d|| � � t j |� � Y d}~dS d}~ww xY w)z)Log *message* on any error & suppress it.Nzcaught error %r on %s)� Exception�logger�error�
sentry_sdk�capture_exception)�message�es r8 �log_and_suppress_errorrP n sq � � � �(�
�������� (� (� (����,�a��9�9�9��$�Q�'�'�'�'�'�'�'�'�'�����(���s �
�
A�0A
�
Ac � �( K � t d� � 5 t j � t j � � � � d d d � � n# 1 swxY w Y t
� dt j � � � � t d� � 5 g }t j
d� � 4 �d {V �� dt v rOt j �
� � |� t j � � � � � |� |� � � � � t j |� � d {V �� d d d � � �d {V �� n# 1 �d {V ��swxY w Y d d d � � n# 1 swxY w Y t% |d� �� � D ]s}t d� � 5 t
� d |j j |j j � � |� � � � d {V �� d d d � � n# 1 swxY w Y �tt d
� � 5 t- j � � � d {V �� d d d � � n# 1 swxY w Y t j d� � x}�At d� � 5 t j |� � � d {V �� d d d � � n# 1 swxY w Y t d
� � 5 | � � � d d d � � n# 1 swxY w Y t5 � � t
� dt j � � � � d S )Nz)marking the start of the shutdown processzshutdown task starting, pid=%sz4preventing new messages (if any) processing to start�
�
sensor_serverc � � | j S r4 )�SHUTDOWN_PRIORITY)�ps r8 �<lambda>z _shutdown_task.<locals>.<lambda>� s � �A�4G� r: )�keyz,This happened while shutting down a plugin!!zShutting down %s.%s...zshutting down IAID API�web_server_restart_taskzwaiting for web server restartz
stopping loopzshutdown task finished, pid=%s)rP r
�sensor�
shutting_down�timerJ �info�os�getpid�asyncio�timeoutr rS �close�append�wait_closed�shutdown�gather�sorted� __class__rE rD r �get�wait_for�stopr, )r= �the_sink�plugin_list�_tasks�plugin�restart_tasks r8 �_shutdown_taskrq x s� � � � � � K� L� L� 1� 1��
�#�#�D�I�K�K�0�0�0�1� 1� 1� 1� 1� 1� 1� 1� 1� 1� 1���� 1� 1� 1� 1� �K�K�0�"�)�+�+�>�>�>� �>�
�
�
*�
*� ���?�2�&�&� *� *� *� *� *� *� *� *��!�#�#���%�%�'�'�'��
�
�a�o�9�9�;�;�<�<�<��M�M�(�+�+�-�-�.�.�.��.�&�)�)�)�)�)�)�)�)�
*� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *� *���� *� *� *� *�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*� ��*G�*G�H�H�H� $� $��
#�:�
�
�
$�
$�
�K�K�(�� �+�� �)�
�
�
� �/�/�#�#�#�#�#�#�#�#�#�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$��
� 8� 9� 9� /� /�#�,�.�.�.�.�.�.�.�.�.�/� /� /� /� /� /� /� /� /� /� /���� /� /� /� /� ��7�8�8�8��E�
#�$D�
E�
E� 1� 1��"�<�0�0�0�0�0�0�0�0�0� 1� 1� 1� 1� 1� 1� 1� 1� 1� 1� 1���� 1� 1� 1� 1�
�� 0� 0� � �� � ����� � � � � � � � � � ���� � � � � �N�N�N�
�K�K�0�"�)�+�+�>�>�>�>�>s� �1A�A�A�E5�2BE�E5�
E" �"E5�%E" �&E5�5E9�<E9�#AG:�:G> �G> �H;�;H?�H?�+J�J�J�,K
�
K�Kc � � t � d| � � t j � � }t j � | � � |_ d|_ t j |_ t � � rd|_ nd|_ t j
j � � � |_ |� � � nC# t"