gdZddlZddlZddlmZddlmZddlmZ ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZmZejeZdZdZdZ deddde fZ!eddee"e"e"ffdZ#de$de$fdZ%de&de&fdZ'de&ddfdZ(d"dZ)ed#dZ*ed#d Z+ed!kr e)dSdS)$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 . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see N) lru_cache)iglob)sha1)cycle)Path)NamedTemporaryFile)Tuple)run_coro)CleanupStorage)skip_for_im360)get_all_domainsget_vhosts_dirsIMUNIFYz .revisiumz.imunifyz.revisium_antivirus_cache*backup)maxsizereturnctt}tt}||z}t d| t | | t | dfS)z-Get backup file slices for splitting it apartN)len ENCRYPT_KEY hash_func hexdigestslice)key_size digest_size meta_sizes ^/opt/imunify360/venv/lib/python3.11/site-packages/imav/migrations/005_plesk_cleanup_storage.py_get_backup_file_slicesr3ss;Hikk++--..K;&I dYJ yj;,'' {lD!!   encryptedc Ztdt|ttD}t \}}}||}||}||}|tksJt ||dksJ|S)z'Decrypt ex-Revisium backup file contentc3&K|] \}}||z V dSN).0cks r zdecrypt..Es*KK1a!eKKKKKKrzlatin-1)bytesziprrrrrdecode)r decrypted content_slice key_slice digest_slicecontentkeydigests rdecryptr3CsKKIu[7I7I(J(JKKKKKI-D-F-F*M9l &G I C | $F +     W   ' ' ) )V]]9-E-E E E E E Nrfilenamec t|}|jjjt}t |d}t j||j tS)z;Figure out what the original filename of ex-Revisium backup document_root) rparentname removeprefixREVISIUM_DIR_PREFIXr ospathjoin removesuffixBACKUP_FILE_SUFFIX)r4r< domain_idorig_dirs rget_orig_filenamerBSse >>D "'445HIII  +Od}~wwxYwdS)Nrz&Failed to transit a backup file %r: %r) rr;r<r=rBACKUP_LOCATIONrZ Exceptionloggerwarning)filees rmainrbusbgl>#3#3SK?KKKLLNN N 4  N N N NNCT1 M M M M M M M M NNNsA  A:A55A:Fc *|rdStdSr#)rbmigratordatabasefakekwargss rmigrateri}s FFFFFrc dSr#r$rds rrollbackrksDr__main__)rN)F),__doc__loggingr; functoolsrglobrhashlibrr itertoolsrpathlibrtempfilertypingr defence360agent.utilsr imav.malwarelib.cleanup.storager imav.migration_utils.otherr imav.migration_utils.revisiumr r getLogger__name__r^rr:r?r\rrr)r3strrBrZrbrirkr$rrr}s`* %%%%%%''''''******::::::555555IIIIIIII  8 $ $ !   1 ueU':!;     u      NNNNNN S T    4NNNN         zDFFFFFr