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/entitlements/__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/entitlements/__pycache__/repo.cpython-310.pyc
o

F��c�<�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZddlm
Z
mZmZmZmZmZmZddlmZddlmZe��ZGdd�dej�ZdS)�N)�Any�Dict�List�Optional�Tuple�Union)�apt�contract�event_logger�
exceptions�messages�system�util)�base)�ApplicationStatusc	sTeZdZdZdZdZdZedee	e
dffdd��Zedee
fdd	��Z
defd
d�Zeejde
fdd
���Zd)dedefdd�Zd)dd�Zd)deddfdd�Zdeeeejffdd�Zdd�Z	d)dee
efdee
efdedef�fdd�
Z			d*deee
d ed!eddfd"d#�Z d)deddfd$d%�Z!	d+d&edefd'd(�Z"�Z#S),�RepoEntitlementz*/etc/apt/sources.list.d/ubuntu-{name}.listz$/etc/apt/preferences.d/ubuntu-{name}NF�returncC�dS�N���selfrr�</usr/lib/python3/dist-packages/uaclient/entitlements/repo.py�repo_pin_priority#sz!RepoEntitlement.repo_pin_prioritycCsJg}|jjj�|ji��di�}|r#|�di�}t�|�dg��}|}|S)zdebs to install on enablement�entitlement�
directives�additionalPackages)�cfg�machine_token_file�entitlements�get�name�copy)r�packagesrr�additional_packagesrrrr#'s
��
�zRepoEntitlement.packagescCs tjt|j�d�}t�|�|S)z%Check if system needs to be rebooted.)�installed_pkgs)r
�
should_reboot�setr#�event�needs_reboot)r�reboot_requiredrrr�_check_for_reboot:s
�
z!RepoEntitlement._check_for_rebootcCrrrrrrr�
repo_key_fileBszRepoEntitlement.repo_key_file�silentcCs�|j|d�|jr2|jr2t|j�dkrdd�|j�nd}t�d�|��t�t	j
j|jd��d
S|��t�t	j
j|jd��|jdd	�d
S)z�Enable specific entitlement.

        @return: True on success, False otherwise.
        @raises: UserFacingError on failure to install suggested packages
        �r-rz: � �zSkipping installing packages{}��title�install)�	operationT)�setup_apt_config�supports_access_only�access_only�lenr#�joinr(�info�formatr�ACCESS_ENABLED_TMPLr2�install_packages�ENABLED_TMPL�_check_for_reboot_msg)rr-�packages_strrrr�_perform_enableGs���zRepoEntitlement._perform_enablecCs"t|d�r	|��|j|d�dS)N�remove_packagesr.T)�hasattrrB�_cleanup�rr-rrr�_perform_disable]s
z RepoEntitlement._perform_disablecCs|j|d�dS)z4Clean up the entitlement without checks or messagingr.N)�remove_apt_configrErrrrDcszRepoEntitlement._cleanupcCs�|jjj�|ji�}|�di��di�}|�d�}|s&tjtjj	|j
d�fStjtj
jd�}t�d�	|�|�}|rDtjtjj	|j
d�fStjtjj	|j
d�fS)Nrr�aptURLr1)�	error_msgz	{}/ubuntu)rrrr r!r�DISABLEDr�NO_APT_URL_FOR_SERVICEr;r2r�get_apt_cache_policy�APT_POLICY_FAILED�msg�re�search�ENABLED�SERVICE_IS_ACTIVE�SERVICE_NOT_CONFIGURED)r�entitlement_cfgr�repo_url�policy�matchrrr�application_statusgs,
��
����z"RepoEntitlement.application_statuscCsP|jj|jd�}tdd�t�|����d�D��rdS|sdSt|t�|�v�S)z�Check if apt url delta should be applied.

        :param apt_url: string containing the apt url to be used.

        :return: False if apt url is already found on the source file.
                 True otherwise.
        �r!css�|]}|�d�VqdS)�#N)�
startswith)�.0�linerrr�	<genexpr>�s
��
�z<RepoEntitlement._check_apt_url_is_applied.<locals>.<genexpr>�
FT)	�repo_list_file_tmplr;r!�allr
�	load_file�strip�split�bool)r�apt_url�apt_filerrr�_check_apt_url_is_applied�s�z)RepoEntitlement._check_apt_url_is_applied�orig_access�deltas�allow_enablecst��|||�r
dS|�di�}|�di�}|�d�}|�d�}|j�d�}|r/|r/|��}	n|��\}	}
|	tjkr<dS|�	|�sot
�d|j�|�di�}|�di��d�}|rg|j
j|jd	�}
t�|
|�|��|��|r�t
�d
�d�|���|j|d�dS)
a1Process any contract access deltas for this entitlement.

        :param orig_access: Dictionary containing the original
            resourceEntitlement access details.
        :param deltas: Dictionary which contains only the changed access keys
        and values.
        :param allow_enable: Boolean set True if allowed to perform the enable
            operation. When False, a message will be logged to inform the user
            about the recommended enabled service.

        :return: True when delta operations are processed; False when noop.
        TrrrHrzstatus-cacheFz5Updating '%s' apt sources list on changed directives.rYz-Installing packages on changed directives: {}�, )�package_list)�super�process_contract_deltasr r�
read_cache�"_check_application_status_on_cacherXrrJrh�loggingr:r!r`r;r�remove_auth_apt_reporGr5r9r=)rrirjrk�delta_entitlement�delta_directives�
delta_apt_url�delta_packages�status_cacherX�_�orig_entitlement�old_url�
repo_filename��	__class__rrro�s@




���z'RepoEntitlement.process_contract_deltasTrm�cleanup_on_failure�verbosecCs�|s|j}|s	dS|j�dg�}t�|�sdS|r#t�dj|jd��|j	r/ddi}gd�}ni}g}zt
jj|jd�}tj
|||j|d�WdStjyW|rV|���w)	a)Install contract recommended packages for the entitlement.

        :param package_list: Optional package list to use instead of
            self.packages.
        :param cleanup_on_failure: Cleanup apt files if apt install fails.
        :param verbose: If true, print messages to stdout
        N�pre_installzInstalling {title} packagesr1�DEBIAN_FRONTEND�noninteractive)z--allow-downgradesz$-o Dpkg::Options::="--force-confdef"z$-o Dpkg::Options::="--force-confold")r#�apt_optionsrI�env)r#�	messagingr r�handle_message_operationsr(r:r;r2�apt_noninteractiver�ENABLED_FAILEDr�run_apt_install_commandrNr�UserFacingErrorrD)rrmrr��msg_opsr�r�rNrrrr=�s6

��z RepoEntitlement.install_packagescCs�d}d}d}|jjs|jjr't�d|jjtj�}t�d|jjtj�}tjj	}n |jj
s/|jjrGt�d|jj
tj�}t�d|jjtj�}tjj}tj
|||d�|jj|jd�}|jjj�|j�}|d�di�}|d�di�}|�d	�}	|	s�|jjd
}
|�d�s�t�|j�}|�|
|j�}|r�|�d	�}	|	s�|
}	t�d|j�|�d
�}
|
s�t�d�|j���|�d�}|s�t�|j��|�d�}|s�t�d�|j|jj���|jr�|j s�t�d�|j t!j"j|jd�j#���|j$j|jd�}t�%|||j |j�g}t&j'�(tj)��s	|�*d�t&j'�(tj+��s|�*d�|�r>|�s't,�-d�d�.|���ztj/|d�Wntj�y=|�0��wt�1|||	||j2�|�sQt,�-t!j3�zt�4�WdStj�yh|j0dd��w)z�Setup apt config based on the resourceToken and directives.
        Also sets up apt proxy if necessary.

        :raise UserFacingError: on failure to setup any aspect of this apt
           configuration
        N�http�https)�
http_proxy�https_proxy�proxy_scoperYrr�obligations�
resourceToken�machineToken�enableByDefaultzWNo resourceToken present in contract for service %s. Using machine token as credentials�aptKeyz6Ubuntu Pro server provided no aptKey directive for {}.rH�suitesz%Empty {} apt suites directive from {}z:Cannot setup apt pin. Empty apt repo origin value '{}'.
{}r1zapt-transport-httpszca-certificateszInstalling prerequisites: {}rl)r#F)�run_apt_update)5r�global_apt_http_proxy�global_apt_https_proxyr�validate_proxy�PROXY_VALIDATION_APT_HTTP_URL�PROXY_VALIDATION_APT_HTTPS_URLr�
AptProxyScope�GLOBAL�ua_apt_http_proxy�ua_apt_https_proxy�UACLIENT�setup_apt_proxyr`r;r!rrr �
machine_tokenr	�UAContractClient�request_resource_machine_accessrr�warningr2rr��MissingAptURLDirective�contract_urlr�originrr�rN�repo_pref_file_tmpl�add_ppa_pinning�os�path�exists�APT_METHOD_HTTPS_FILE�append�CA_CERTIFICATES_FILEr(r:r9r�rG�add_auth_apt_repor,�APT_UPDATING_LISTS�run_apt_update_command)rr-r�r��scoper|�resource_cfgrr��tokenr��client�machine_accessr�rU�repo_suites�repo_pref_file�prerequisite_pkgsrrrr5s���
���

�
�
�


�����

�����z RepoEntitlement.setup_apt_configr�c	Cs�t��d}|jj|jd�}|jjj|j�di�}|�di�}|�d�}|s-t	�
|j��t�|||j
�t�||�|jrK|jj|jd�}t�|�|r[|sUt�tj�t��dSdS)z�Remove any repository apt configuration files.

        :param run_apt_update: If after removing the apt update
            command after removing the apt files.
        �seriesrYrrrHN)r
�get_platform_infor`r;r!rrrr rr�rrsr,�remove_apt_list_filesrr��ensure_file_absentr(r:rr�r�)	rr�r-r�r|r�access_directivesrUr�rrrrG�s&�

�z!RepoEntitlement.remove_apt_config)F)NTT)TF)$�__name__�
__module__�__qualname__r`r�r�r��propertyr�int�strrrr#rer+�abc�abstractmethodr,rArFrDrrrr�NamedMessagerXrhrrror=r5rG�
__classcell__rrr}rrsd

��
�
���?�
���
�3���r)r�r"rrr�rO�typingrrrrrr�uaclientrr	r
rrr
r�uaclient.entitlementsr�(uaclient.entitlements.entitlement_statusr�get_event_loggerr(�
UAEntitlementrrrrr�<module>s $	

Anon7 - 2022
AnonSec Team