Hacked By AnonymousFox

Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/advanced/rpc/endpoints/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/advanced/rpc/endpoints/__pycache__/backup.cpython-311.pyc

�

��g�$���dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZddlmZmZmZmZmZmZmZmZdd	lmZmZeje��Zd
Zddd
�Z ee eddd�e �ee iZ!d�Z"Gd�de
e���Z#dS)u

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)�BackupConfig)�
LicenseCLN)�CLNError)�ValidationError)�CommonEndpoints�bind�wraps)�Acronis�BackupException�
CloudLinux�CloudLinuxBase�CloudLinuxOnPremise�R1Soft�get_available_backends_names�get_backend)�Scope�	Singletonz�
Error with one of the next reasons:
* Not found linked backup for the server
* Not found linked cloudlinux user for the server
* IP of server is different in last time
zUsername should be providedzPassword should be provided)�username�passwordz!Encryption key should be providedzIP should be provided)�encryption_key�ipc�<��t����fd���}|S)Nc�����K�t��di��}�fd�|���D��}|r"td�|������|i����d{V��S)N�backendc�D��g|]\}}��|���|��S�)�get)�.0�field�	error_msg�kwargss   ��b/opt/imunify360/venv/lib/python3.11/site-packages/imav/malwarelib/advanced/rpc/endpoints/backup.py�
<listcomp>z:validate_backend_args.<locals>.wrapper.<locals>.<listcomp>Gs?���
�
�
� ��y��:�:�e�$�$�
��
�
�
��
)�REQUIRED_FIELDSr�itemsr�join)�argsr!�required_options�errors�fs `  �r"�wrapperz&validate_backend_args.<locals>.wrapperDs�������*�.�.�v�i�/@�"�E�E��
�
�
�
�$4�$:�$:�$<�$<�
�
�
��
�	5�!�$�)�)�F�"3�"3�4�4�4��Q��'��'�'�'�'�'�'�'�'�'r$)r	)r,r-s` r"�validate_backend_argsr.Cs3���
�1�X�X�
(�
(�
(�
(��X�
(��Nr$c�|��eZdZejZd\ZZZZ	�fd�Z
ed���Ze
edd��d�����Zd�Zd�Zd	�Zedd
��d���Zedd��dd���Zedd��d���Zedd��d���Zedd��d���Zd�Zd�Z�xZS)�BackupEndpoints)�not_running�init�backup�donec���t���|��|j|_dx|_|_dx|_|_d|_dS)Nr)	�super�__init__�NOT_RUNNING�_status�_current_backend�_error�
_init_task�_backup_task�_backup_started_time)�self�sink�	__class__s  �r"r7zBackupEndpoints.__init__YsQ���
����������'���.2�2�����.2�2���$�+�$%��!�!�!r$c�@�tj��|jz
dkS)Ni,)�timer>�r?s r"�_backup_pendingzBackupEndpoints._backup_pending`s���y�{�{�T�6�6��?�?r$zbackup-systemsr2c��K�tj��rtd���tj��}|jrE|js>|j|jkrtd���|j|j	krtd���t�d��d|_|�|j
di|����|_|j�|j��|j|_||_dS)Nz*This action is not allowed in demo versionz,Backup initialization is already in progressz%Backup process is already in progresszStarting init taskz,Backup initialization process is in progressr)r�is_demor�asyncio�get_event_loopr:r;r9�INIT�BACKUP�logger�info�create_taskr2�_task�add_done_callback�_init_task_done)r?rr!�loops    r"r2zBackupEndpoints.initds��������	P�!�"N�O�O�O��%�'�'��� �	O���	O��|�t�y�(�(�%�B�����|�t�{�*�*�%�&M�N�N�N����(�)�)�)�����%�%�l�g�l�&<�&<�V�&<�&<�=�=��
��
�$�$�T�%9�:�:�:��y��� '���=�=r$c���K�|jsh|drbt|d��|_|j|jkr:|j����d{V��r|j|_dSd|_dSdSdSdS)N�
backup_systemzNo backups found!)r:rr9r8�check_state�DONEr;)r?�confs  r"�_set_current_backendz$BackupEndpoints._set_current_backend{s������$�	6��o�)>�	6�$/��_�0E�$F�$F�D�!��|�t�/�/�/��.�:�:�<�<�<�<�<�<�<�<�6�#'�9�D�L�L�L�"5�D�K�K�K�	6�	6�	6�	6�0�/r$c���K�|d|jkr4|j����d{V��}|�|��t	|jt
��r�|j|jkr�|j�8|j�	���d{V��rd|_|j
x|d<|_nE|j����d{V��}|�|jrd|d<n|j
x|d<|_n||d<|S)N�stater�progress)
rJr:�show�update�
isinstancer
r9rKr;rUrV�get_backup_progressrE)r?�status�
advanced_datar[s    r"�_include_init_stages_infoz)BackupEndpoints._include_init_stages_info�s*�����'�?�d�i�'�'�"&�"7�"<�"<�">�">�>�>�>�>�>�>�M��M�M�-�(�(�(��t�,�n�=�=�	2�����+�+��{�&��.�:�:�<�<�<�<�<�<�<�<�?�#'�D�K�59�Y�>�F�7�O�d�l��!%�!6�!J�!J�!L�!L�L�L�L�L�L�L���#��+�C�-.��z�*�*�:>��B��w��$�,�,�)1�F�:�&��
r$c���K�|�|���d{V��|j|d<|j|d<t|jdd��|d<t|jdd��|d<|j�*|j|jkrdx|_|_|j|_|jr�	|�|���d{V��}n�#tj	$r�t$r�}dt|��vr#|jrt�d|��nZ|jtkrH|j����d{V��}|�d��tjkrd	|d<n|�Yd}~nd}~wwxYw|S)
NrZ�error�log_path�namerTzNo backup for hostzIError %s will be ignored for 5 minutes after init state has been finishedr`z;Backup is unpaid! Please, check it out in your CLN account.)rXr9r;�getattrr:rJr8rbrH�CancelledError�	Exception�strrErLrMr�checkr�UNPAID)r?r`�e�resps    r"�_get_advanced_statusz$BackupEndpoints._get_advanced_status�s������'�'��/�/�/�/�/�/�/�/�/��,��w���+��w��$�T�%:�J��M�M��z��")�$�*?���"N�"N�����;�"�t�|�t�y�'@�'@�26�6�D�K�$�/��+�D�L�� �	�
�#�=�=�f�E�E�E�E�E�E�E�E�����)�
�
�
���
�
�
�'�3�q�6�6�1�1�d�6J�1��K�K�=�������*�j�8�8�!%�!6�!<�!<�!>�!>�>�>�>�>�>�>�D��x�x��)�)�Z�->�>�>�:��w���
�G����������#
����&�
s�B9�9E*�BE%�%E*zextended-statusc��K�t������di��}|�|���d{V��}d|iS�N�
BACKUP_SYSTEMr')r�config_to_dictrro)r?r`s  r"�extended_statuszBackupEndpoints.extended_status�s[�������.�.�0�0�4�4�_�b�I�I���0�0��8�8�8�8�8�8�8�8���� � r$r`Nc��vK�t������di��}d|iSrq)rrsr)r?�userr`s   r"r`zBackupEndpoints.status�s6�������.�.�0�0�4�4�_�b�I�I���� � r$�listc��"K�t��S�N)rrDs r"rwzBackupEndpoints.list�s����+�-�-�-r$�disablec��dK�dx|_|_|j|_|jdi|���d{V��dS)Nr)r:r;r8r9rz)r?rr!s   r"rzzBackupEndpoints.disable�sO����.2�2������'����g�o�'�'��'�'�'�'�'�'�'�'�'�'�'r$rkc���K�	d|����d{V��iS#t$rtt���tt
f$r"}tt
|����|�d}~wwxYw)Nr')rkrr�CLN_RESPONSE_ERROR�LookupError�RuntimeErrorrj)r?rrms   r"rkzBackupEndpoints.check�s�����	1��7�=�=�?�?�2�2�2�2�2�2�3�3���	6�	6�	6�!�"4�5�5�5��\�*�	1�	1�	1�!�#�a�&�&�)�)�q�0�����	1���s� �.A0�A+�+A0c�N�t�d��|���}|�Ut|t��rt
|_dSt�d|���t|��|_dSt�d��|j|_	tj
��|_tj
���|j�����|_|j�|j��dS)NzIn init done callbackzBackup init task failed��exc_infozStarting initial backup task)rLrM�	exceptionr^rr}r;rjrKr9rCr>rHrIrNr:�make_backupr=rP�_backup_task_done�r?�futurerms   r"rQzBackupEndpoints._init_task_done�s������+�,�,�,��������=��!�X�&�&�
%�0������ � �!:�Q� �G�G�G�!�!�f�f������K�K�6�7�7�7��;�D�L�(,�	���D�%� '� 6� 8� 8� D� D��%�1�1�3�3�!�!�D��
��/�/��0F�G�G�G�G�Gr$c�>�t�d��|���}|�`t�d|���t|t��rt|��|_dSdt|��z|_dS|j|_dS)NzIn backup done callbackzInitial backup task failedr�zUnknown error: )	rLrMr�r^rrjr;rVr9r�s   r"r�z!BackupEndpoints._backup_task_done�s������-�.�.�.��������=����9�A��F�F�F��!�_�-�-�
9�!�!�f�f�����/�#�a�&�&�8������9�D�L�L�Lr$ry)�__name__�
__module__�__qualname__r�IM360�SCOPEr8rJrKrVr7�propertyrEr.rr2rXrbrortr`rwrzrkrQr��
__classcell__)rAs@r"r0r0Ts���������K�E�&M�#�K��v�t�&�&�&�&�&��@�@��X�@��	�T�
�F�#�#�>�>�$�#���>�*	6�	6�	6����8$�$�$�L
�T�
�-�.�.�!�!�/�.�!�
�T�
�H�%�%�!�!�!�&�%�!�
�T�
�F�#�#�.�.�$�#�.�
�T�
�I�&�&�(�(�'�&�(�

�T�
�G�$�$�1�1�%�$�1�H�H�H�$
%�
%�
%�
%�
%�
%�
%r$r0)�	metaclass)$�__doc__rH�loggingrC� defence360agent.contracts.configr�!defence360agent.contracts.licenser�defence360agent.internals.clnr�defence360agent.rpc_toolsr� defence360agent.rpc_tools.lookuprrr	�%defence360agent.subsys.backup_systemsr
rrr
rrrr�defence360agent.utilsrr�	getLoggerr�rLr}�PLAIN_AUTH_FIELDSr&r.r0rr$r"�<module>r�s�����*������������9�9�9�9�9�9�8�8�8�8�8�8�2�2�2�2�2�2�5�5�5�5�5�5�I�I�I�I�I�I�I�I�I�I�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�3�2�2�2�2�2�2�2�	��	�8�	$�	$����.�-����
�
�
�=�%�
�
��
�
�*������"o%�o%�o%�o%�o%�o��o%�o%�o%�o%�o%�o%r$

Hacked By AnonymousFox1.0, Coded By AnonymousFox