403Webshell
Server IP : 159.223.102.202  /  Your IP : 216.73.217.92
Web Server : nginx/1.26.0
System : Linux Gen1-cloudpanel2ubuntu2404-1vcpu-1gb-nyc1-01 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User : albasshbotta ( 1021)
PHP Version : 8.2.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/uaclient/files/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/uaclient/files/__pycache__/files.cpython-312.pyc
�

|f�%���ddlZddlZddlZddlmZddlmZmZmZddlm	Z	m
Z
mZmZm
Z
ddlmZe
j �Zej$e
j&e��ZGd�d�ZGd�d	e�ZGd
�d�Zy)�N)�datetime)�Any�Dict�Optional)�defaults�event_logger�
exceptions�system�util)�PublicMachineTokenDatac��eZdZejdfdededefd�Zedefd��Z	edefd��Z
ed	��Zd
efd�Zde
efd�Zd
�Zy)�UAFileT�name�	directory�privatec��||_||_||_tjj|j|j�|_y�N)�
_directory�
_file_name�_is_private�os�path�join�_path)�selfrrrs    �6/usr/lib/python3/dist-packages/uaclient/files/files.py�__init__zUAFile.__init__s8��$������"����W�W�\�\�$�/�/�4�?�?�C��
��returnc��|jSr)r�rs rrzUAFile.paths���z�z�rc��|jSr)rr!s r�
is_privatezUAFile.is_privates�����rc�T�tjj|j�Sr)rr�existsr!s r�
is_presentzUAFile.is_present"s���w�w�~�~�d�i�i�(�(r�contentc��|jrtjntj}	tj
j
|j�tjk(r"t	j|jd��nt	j|j�tj|j
||�y#t$rY�-wxYw)Ni�)�mode)
r#r�ROOT_READABLE_MODE�WORLD_READABLE_MODErr�basenamer�PRIVATE_SUBDIR�makedirs�OSErrorr
�
write_file)rr'�	file_modes   r�writezUAFile.write&s������
�'�'��-�-�	�	��w�w������0�H�4K�4K�K����D�O�O�%�8����D�O�O�,�	���$�)�)�W�i�8���	��	�s�A;C�	C�Cc��d}	tj|j�}|S#t$r$tjd|j�Y|SwxYw)Nz(Tried to load %s but file does not exist)r
�	load_filer�FileNotFoundError�LOG�debug)rr's  r�readzUAFile.read7sS����	M��&�&�t�y�y�1�G����!�	M��I�I�@�$�)�)�L���	M�s�%�)A�Ac�B�tj|j�yr)r
�ensure_file_absentrr!s r�deletez
UAFile.delete?s���!�!�$�)�)�,rN)�__name__�
__module__�__qualname__r�DEFAULT_DATA_DIR�str�boolr�propertyrr#r&r2rr8r;�rrrrs���"�2�2��		D��	D��	D��		D���c����� �D� �� ��)��)�9�S�9�"�h�s�m��-rrc�$��eZdZdef�fd�Z�xZS)�
UserCacheFilerc�N��t�|�|tj�d��y)NF)rr)�superrr
�get_user_cache_dir)rr�	__class__s  �rrzUserCacheFile.__init__Ds%���
����F�5�5�7��	�	
r)r<r=r>r@r�
__classcell__)rIs@rrErECs���
�S�
�
rrEc�f�eZdZejdfdedeefd�Zdefd�Z	d�Z
deefd	�Zed
��Z
ed��Zd�Zedeefd
��Zed��Zedefd��Zedeefd��Zed��Zedeefd��Zedd��Zedd��Zedd��Zed��Zed��Zy)�MachineTokenFileNr�machine_token_overlay_pathc���tj}t||dztjz�|_t||d�|_||_d|_d|_d|_	y)N�/F)
r�MACHINE_TOKEN_FILErr-�private_file�public_filerM�_machine_token�
_entitlements�_contract_expiry_datetime)rrrM�	file_names    rrzMachineTokenFile.__init__Ksc��
�/�/�	�"��y�3���)@�)@�@�
���"�)�Y��>���*D��'�"���!���)-��&r�private_contentc���tj�r�tj|tj��}|j
j
|�tj|�jd��}tj|tj��}|jj
|�d|_d|_d|_
ytj��)z8Update the machine_token file for both pub/private files��clsF)�	keep_noneN)r�we_are_currently_root�json�dumps�DatetimeAwareJSONEncoderrQr2r�	from_dict�to_dictrRrSrTrUr	�NonRootUserError)rrW�private_content_str�public_content�public_content_strs     rr2zMachineTokenFile.writeZs����%�%�'�"&�*�*��T�%B�%B�#��
���#�#�$7�8�4�=�=����g��g�&�
�"&����D�$A�$A�"��
���"�"�#5�6�"&�D��!%�D��-1�D�*��-�-�/�/rc���tj�rJ|jj�|jj�d|_d|_d|_ytj��)z!Delete both pub and private filesN)
rr\rRr;rQrSrTrUr	rbr!s rr;zMachineTokenFile.deletersY���%�%�'����#�#�%����$�$�&�"&�D��!%�D��-1�D�*��-�-�/�/rrc���tj�r
|j}n|j}|j	�}|sy	tj|tj��}|S#t$rY|SwxYw�NrY)	rr\rQrRr8r]�loads�DatetimeAwareJSONDecoder�	Exception)r�file_handlerr's   rr8zMachineTokenFile.read~ss���%�%�'��,�,�L��+�+�L��#�#�%����	��j�j��d�.K�.K�L�G�����	����	�s�%A)�)	A6�5A6c��tj�r.|jjxr|jjS|jjSr)rr\rRr&rQr!s rr&zMachineTokenFile.is_present�sC���%�%�'��#�#�.�.�O�4�3D�3D�3O�3O�O��#�#�.�.�.rc���|jsY|j�}|r@|jr4|j|j�}|rt	j
||��||_|jS)zAReturn the machine-token if cached in the machine token response.)�	base_dict�overlay_dict)rSr8rM�parse_machine_token_overlayr�depth_first_merge_overlay_dict)rr'�machine_token_overlays   r�
machine_tokenzMachineTokenFile.machine_token�sl���"�"��i�i�k�G��4�:�:�(,�(H�(H��3�3�)�%�)��7�7�")�%:��#*�D���"�"�"rc�v�tj|�}tj|tj
��Srh)r
r4r]rirrj)rrM�machine_token_overlay_contents   rrqz,MachineTokenFile.parse_machine_token_overlay�s5��(.�(8�(8�&�)
�%��z�z�)��-�-�
�	
rc�R�t|j�r|jddSy)N�machineTokenInfo�accountInfo�rArtr!s r�accountzMachineTokenFile.account�s*����"�"�#��%�%�&8�9�-�H�H�rc��|jr|jS|jsiS|j|j�|_|jS)z9Return configured entitlements keyed by entitlement named)rTrt�get_entitlements_from_tokenr!s r�entitlementszMachineTokenFile.entitlements�sQ������%�%�%��!�!��I�!�=�=����
����!�!�!rrtc�Z�ddlm}|siSi}|jdi�jd�}|siStd�|jdg�D��}td�|jdg�D��}|j	�D]"\}}d	|i}||vr|||d
<||�|||<�$|S)z�Return a dictionary of entitlements keyed by entitlement name.

        Return an empty dict if no entitlements are present.
        r)�apply_contract_overridesrx�contractInfoc3�`K�|]&}|jd�|jd�f���(y�w)�type�tokenN��get��.0�es  r�	<genexpr>z?MachineTokenFile.get_entitlements_from_token.<locals>.<genexpr>�s-����
���U�U�6�]�A�E�E�'�N�+�
�s�,.�resourceTokensc3�BK�|]}|jd�|f���y�w)r�Nr�r�s  rr�z?MachineTokenFile.get_entitlements_from_token.<locals>.<genexpr>�s%����
���U�U�6�]�A��
�s��resourceEntitlements�entitlement�
resourceToken)�uaclient.contractr�r��dict�items)	rtr�r~r��tokens_by_name�ent_by_name�entitlement_name�	ent_value�entitlement_cfgs	         rr}z,MachineTokenFile.get_entitlements_from_token�s���	?���I���$�(�(�);�R�@�D�D��
����I��
�"�&�&�'7��<�
�
���
�!�%�%�&<�b�A�
�
��,7�+<�+<�+>�	=�'��i�,�i�8�O��>�1�3A�$�4���0�
%�_�5�-<�L�)�*�	=��rc��|jsA|jjdi�jdi�jdd�|_|jS)z6Return a datetime of the attached contract expiration.rxr��effectiveToN)rUrtr�r!s r�contract_expiry_datetimez)MachineTokenFile.contract_expiry_datetime�sR���-�-��"�"�&�&�'9�2�>���^�R�(���]�D�)�
�*��-�-�-rc�,�t|j�S)z<Report whether this machine configuration is attached to UA.rzr!s r�is_attachedzMachineTokenFile.is_attached�s���D�&�&�'�'rc��|j�y|jj�tj�j�z
}|jS)aReport num days until contract expiration based on effectiveTo

        :return: A positive int representing the number of days the attached
            contract remains in effect. Return a negative int for the number
            of days beyond contract's effectiveTo date.
        N)r��dater�utcnow�days)r�deltas  r�contract_remaining_daysz(MachineTokenFile.contract_remaining_days�sF���(�(�0���-�-�2�2�4�x���7H�7M�7M�7O�O���z�z�rc�r�|jr+|jjdi�jd�Sy)N�activityInfo�
activityToken�rtr�r!s r�activity_tokenzMachineTokenFile.activity_tokens9������%�%�)�)�.�"�=�A�A���
�rc�r�|jr+|jjdi�jd�Sy)Nr��
activityIDr�r!s r�activity_idzMachineTokenFile.activity_id
s2������%�%�)�)�.�"�=�A�A�,�O�O�rc�r�|jr+|jjdi�jd�Sy)Nr��activityPingIntervalr�r!s r�activity_ping_intervalz'MachineTokenFile.activity_ping_intervals9������%�%�)�)�.�"�=�A�A�&��
�rc��|jr;|jjdi�jdi�jd�Sy)Nrxr��idr�r!s r�contract_idzMachineTokenFile.contract_idsA������"�"�&�&�'9�2�>���^�R�(���T��
�
rc�T�|jr|jjdg�Sy)Nr�r�r!s r�resource_tokensz MachineTokenFile.resource_tokens"s(������%�%�)�)�*:�B�?�?�r)rz
Optional[str])rz
Optional[int])r<r=r>rr?r@rrr�r2r;r8rBr&rtrqr{r~�staticmethodrr}rr�r��intr�r�r�r�r�r�rCrrrLrLJs��"�2�2�48�
.��
.�%-�S�M�
.�0�T�0�0
0��h�t�n���/��/��#��#�"
����$�����
�	"��	"��!�4�!��!�F�	.�(�8�*<�	.��	.��(��(��
��#��
��
���������
�����������rrL)r]�loggingrr�typingrrr�uaclientrrr	r
r�uaclient.contract_data_typesr�get_event_logger�event�	getLogger�replace_top_level_logger_namer<r6rrErLrCrr�<module>r�ss����	��&�&�E�E�?�%��%�%�'���g���:��:�:�8�D�E��2-�2-�j
�F�
�]�]r

Youez - 2016 - github.com/yon3zu
LinuXploit