403Webshell
Server IP : 104.21.4.30  /  Your IP : 162.159.115.11
Web Server : Apache
System : Linux keen-cori.18-142-40-148.plesk.page 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 06:59:36 UTC 2025 x86_64
User : simottodesign.com_2tntp341vs7 ( 10011)
PHP Version : 8.3.31
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/uaclient/__pycache__/actions.cpython-38.pyc
U

2�d�(�
@s�ddlZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZddlmZmZmZddlmZdd	lmZdd
lmZmZmZddlmZmZm Z e�!e�"e#��Z$dZ%d
Z&e	j'e(e)dd�dd�Z*d+e	j'ejdd�dd�Z+dddddd�e	j'e(e)e)e)e(eee(d�dd�Z,ddd�e	j'ee(e)d�dd�Zd,e(eee-dd�d d!�Z.e	j'd"�d#d$�Z/e	j'e(d%�d&d'�Z0e	j'ed(�d)d*�Z1dS)-�N)�List�Optional)�clouds�config�contract�entitlements�
exceptions�	livepatch)�log)�messages)�status)�system�timer�util)�AutoAttachCloudInstance)�identity)�CLOUD_BUILD_INFO�DEFAULT_CONFIG_FILE�DEFAULT_LOG_PREFIX)�AttachmentData�attachment_data_file�timer_jobs_state_file)zua-timer.servicezua-timer.timerzua-auto-attach.pathzua-auto-attach.servicezua-reboot-cmds.servicezubuntu-advantage.service�
)�cfg�token�allow_enable�returncCszddlm}t�|�}tjjtjjd�}z|j||d�}WnNt	j
k
r�}z.t���t
�t|��W5QRXt	���W5d}~XYnX|j�|�tj��|�di��dt�|��}|�d|�zt�|i|jj|�Wn\t	j
t	jfk
�r:}	z4t�t|d	��tj|d
�||�|��|	�W5d}	~	XYnXt �!�}
|
�rV|�d|
�t�t|d	��||�t"�#�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_motd_messages)Ztz)Zcontract_tokenZ
attachment_dtNZmachineTokenInfoZ	machineIdz
machine-id)�attached_at�rzinstance-id)$Zuaclient.timer.update_messagingrr�UAContractClient�datetimeZnow�timezoneZutcZadd_contract_machinerZUrlErrorrZdisable_log_to_console�LOGZ	exception�strZConnectivityErrorZmachine_token_file�writer
Zget_machine_id�cache_clear�getZwrite_cacheZprocess_entitlements_deltar�UserFacingErrorrr�	ua_statusrZupdate_activity_tokenrZget_instance_idr�start)rrrr�contract_clientrZnew_machine_token�eZ
machine_id�excZcurrent_iid�r.�2/usr/lib/python3/dist-packages/uaclient/actions.py�attach_with_token/sL

�


��	r0T)r�cloudrcCs0t�|�}|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.
    )�instanceZ
contractToken)rrN)rr Z%get_contract_token_for_cloud_instancer0)rr1rr+Z
tokenResponserr.r.r/�auto_attachjs
�r3F�)�
assume_yes�
allow_beta�access_only�variant�
extra_args)r�namer5r6r7r8r9c	Cs,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.
    )rr:r8)r5r6Zcalled_namer7r9)rZentitlement_factory�enable)	rr:r5r6r7r8r9Zent_cls�entitlementr.r.r/�enable_entitlement_by_name�s��r=)�simulate_with_token�show_all)rr>r?cCs4|rtj|||d�\}}ntj||d�}d}||fS)z6
    Construct the current Pro status dictionary.
    )rrr?)rr?r)r)Zsimulate_statusr)rr>r?rZretr.r.r/r�s	�r)�filename�return_codesrc
Csfztj|��|d�\}}Wn:tjk
rT}zt�d�|�t|��W5d}~XYnXt�||�dS)zCHelper which runs a command and writes output or error to filename.)Zrcsz{}-errorN)r
Zsubp�splitrZProcessExecutionError�
write_file�formatr$)�cmdr@rA�out�_r,r.r.r/�_write_command_output_to_file�s
(rHrcCs0|jpt|j|j|jtjjtfdd�t	j
D��S)Ncss,|]$}t|tjj�r|jj|jd�VqdS))r:N)�
issubclassrZrepoZRepoEntitlementZrepo_list_file_tmplrDr:)�.0r<r.r.r/�	<genexpr>�s�z#_get_state_files.<locals>.<genexpr>)Zcfg_pathr�log_fileZtimer_log_fileZdaemon_log_filerZua_file�pathrrZENTITLEMENT_CLASSESrr.r.r/�_get_state_files�s���rN)r�
output_dirc
Cs�tdd�|��tdd�|��td�tj�d�|��tdd�|��td	�d
�dd�tD���d
�|��tD]$}td�|�d�||�ddgd�qrt|�}t��r�t	�
�dt�nt	��g}t
|�D]p\}}z0t�t�|��}t�tj�|d�|��|�Wq�tk
�r8}zt�d|t|��W5d}~XYq�Xq�|t�td�D]�}	tj�|	��rNzt�|	�}Wn@tk
�r�}z t�d|	t|��WY��qNW5d}~XYnXt�|�}t���r�t�|	|�t�tj�|tj�|	��|��qNdS)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|krd�|��qS)z.servicez-u {})rD)rJ�sr.r.r/�
<listcomp>�sz collect_logs.<locals>.<listcomp>z{}/journalctl.txtzsystemctl status {}z	{}/{}.txtr�)rANz
user{}.logz&Failed to collect user log file: %s
%s�*zFailed to load file: %s
%s)rHrDr	Z
LIVEPATCH_CMD�join�UA_SERVICESrNrZwe_are_currently_root�pro_logZget_all_user_log_files�USER_LOG_COLLECTED_LIMITZget_user_log_file�	enumerateZredact_sensitive_logsr
Z	load_filerC�osrM�	Exceptionr#Zwarningr$�globr�isfile�basename)
rrO�serviceZstate_filesZuser_log_filesZlog_file_idxrLZcontentr,�fr.r.r/�collect_logs�s~��
�����
�
�����

�ra)rrc
Cs�d}zt��}Wn�tjk
r�}zjt|tj�r@tjtjdd��t|tj	�rXt�tj
��t|tj�r~tjtj
j|jd�dd��t�tj��W5d}~XYnX|s�t�tj��|S)Nzauto-attach-cloud-type-error)Zmsg_code)�
cloud_typez(auto-attach-unsupported-cloud-type-error)rZcloud_instance_factoryrZCloudFactoryError�
isinstanceZCloudFactoryNoCloudErrorr(rZUNABLE_TO_DETERMINE_CLOUD_TYPEZCloudFactoryNonViableCloudErrorZUNSUPPORTED_AUTO_ATTACHZ!CloudFactoryUnsupportedCloudErrorZNonAutoAttachImageErrorZ"UNSUPPORTED_AUTO_ATTACH_CLOUD_TYPErDrb)rr2r,r.r.r/�get_cloud_instance!s4�����rd)T)N)2r!r\ZloggingrZ�typingrrZuaclientrrrrrr	r
rWrrr)r
rrZuaclient.cloudsrrZuaclient.defaultsrrrZuaclient.files.state_filesrrrZ	getLoggerZreplace_top_level_logger_name�__name__r#rVrXZUAConfigr$�boolr0r3r=�intrHrNrardr.r.r.r/�<module>sv 	�>���
�!���
�P�

Youez - 2016 - github.com/yon3zu
LinuXploit