CasperSecurity

Current Path : /lib/python3/dist-packages/uaclient/cli/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/uaclient/cli/__pycache__/enable.cpython-310.pyc

o

��JhD�@s�ddlZddlZddlmZmZmZmZmZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlmZmZddlmZmZmZddlmZmZddlmZddlm Z dd	l!m"Z"m#Z#m$Z$dd
l%m&Z&e�'e�(e)��Z*edde+fd
e+fdeee,effg�Z-	dBde
j.de+dee	j/fdd�Z0de
j.de,deedeede,de,de,fdd�Z1de+dee,efdee,dee,d eee,efd!eee,efde+fd"d#�Z2de
j.d$e,de,de+d%e+de+d&eee,deedeed'e-fd(d)�Z3e j4e j5e �6e j7�d'e8fd*d+����Z9e$d,ej:ej;e9e&j<d-e#e"dej=j>d.�?ej@e
�.�d/��d0�d1d2d3�e"d4ejAj>d,d5�d6d7�e"d8ejBd6d7�e"d9ejCd6d7�e"d:ejDj>d;d<�d1d;d=gd;d>�e"d?ejEd1d7�gd@�gdA�ZFdS)C�N)�Any�Dict�List�
NamedTuple�Optional)
�api�config�contract�entitlements�event_logger�
exceptions�lock�messages�status�util)�ServiceWithDependencies�
_dependencies)�
EnableOptions�EnableResult�_enable)�EnabledService�_enabled_services)�_is_attached)�cli_util)�ProArgument�ProArgumentGroup�
ProCommand)�HelpCategory�_EnableOneServiceResult�success�needs_reboot�error�cfg�access_only�progress_objectc

Cs�t�|�}tj|d||d�}d}d}z tjdd��|j|d�\}}Wd�n1s,wYWntyD}zt��|�d}~ww|s^|durT|j	durT|j	}	nt
j}	tj
d|	d��tdggdgd	�S)
a
    Landscape gets special treatment because it currently not supported by our
    enable API. This function is a temporary workaround until we have a proper
    API for enabling landscape, which will happen after Landscape is fully
    integrated with the contracts backend.
    �	landscape)�called_namer#�
extra_argsFNzcli.enable._enable_landscape)�lock_holder)�progress)�service�reason)�enabled�disabled�reboot_requiredr)r�ProgressWrapperr
�LandscapeEntitlementr
�	RetryLock�enable�	Exception�clear_lock_file_if_present�messager�GENERIC_UNKNOWN_ISSUEr�EntitlementNotEnabledErrorr)
r"r#r'r$r)r%r�fail_reason�er+�r:�5/usr/lib/python3/dist-packages/uaclient/cli/enable.py�_enable_landscape/s>
�������
�r<r*�all_dependencies�enabled_servicesr&�variant�
service_titlecs�g}g}dd�|D��t�fdd�|D�d�}	|	dur/�fdd�|	jD�}�fdd�|	jD�}|D]'}
tj|jdd�}t�||
�}tj	j
||d	�}
|sQtj|
d
�sXtj
||d	��q1|D]}t�||�}tjj
||d�}
tj|
d
�sxtj||d��q[t��fdd�|D�d�}|dur��dur�t�|���}t�|�|j�}tj|jdd�}tj	j
||d	�}
|s�tj|
d
�s�tj
||d	��dSdSdS)
NcSsg|]}|j�qSr:��name��.0�sr:r:r;�
<listcomp>fsz2prompt_for_dependency_handling.<locals>.<listcomp>c3s�|]
}|j�kr|VqdS�NrArC)r*r:r;�	<genexpr>is�z1prompt_for_dependency_handling.<locals>.<genexpr>csg|]
}|j�vr|j�qSr:rArC��enabled_service_namesr:r;rFl�

�csg|]
}|j�vr|j�qSr:rArCrIr:r;rFqrKz features.block_disable_on_enable)r�
path_to_value)�service_being_enabled�incompatible_service)�msg)rM�required_servicec3s.�|]}|j�kr|jr|j�kr|VqdSrG�rB�variant_enabled�variant_namerC)r*r?r:r;rH�s�
�
��)�next�incompatible_with�
depends_onr�is_config_value_truer"r
�	get_titler�INCOMPATIBLE_SERVICE�format�prompt_for_confirmationr�IncompatibleServiceStopsEnable�REQUIRED_SERVICE�RequiredServiceStopsEnablerS)r"r*r=r>r&r?r@�incompatible_services�required_services�dependenciesrN�cfg_block_disable_on_enable�incompatible_service_title�user_msgrP�required_service_titlerR�to_be_enabled_title�enabled_variant_titler:)rJr*r?r;�prompt_for_dependency_handling[s�	�
�
������������
������
rh�json_output�
json_response�processed_services�failed_services�errors�warningscCsb|r/|��|��|rdnd|d<||d<||d<||d<||d<ttj|tjdd	��dSdS)
Nr�failure�resultrkrlrmrnT)�cls�	sort_keys)�sort�print�json�dumpsr�DatetimeAwareJSONEncoder)rirjrkrlrmrnrr:r:r;�_print_json_output�s 	���rx�ent_name�
assume_yesr'�returnc	s�t�|�}	tj||�||d�}
|
j�|
j}t��fdd�|D�d�}|durItjj	|d�}
|	|
j
�|	tjj	|d��tddd||
j
|
jd�d�S|s�z
t
|�|||�|d	�Wn-tjy�}z t�|�|	|j
�|	tjj	|d��tdddd�WYd}~Sd}~wwz_|r�d}ntj|d
�}�dkr�t||||d�}ntt|�|d
�||d�}tj|d�|r�|	tjj	|d��n	|	tjj	|d��|j}|r�|	tjj	dd��|jD]}|	|�q�td|dd�WStj�y$}z1|jd}|d}|d}|d}|	|�|	tjj	|d��tddd||||d�d�WYd}~Sd}~wtj�yU}z$|	|j
�|	tjj	|d��tddd||j
|j|jd�d�WYd}~Sd}~ww)N)r?r#r'c3s2�|]}|j�kr�r|jr|j�kr|VqdSrGrQrC��	real_namer?r:r;rH�s�
��
��z&_enable_one_service.<locals>.<genexpr>)�titleFr*)�typer*r5�message_code)rr r!)r&r?r@)rzr%)r'r$)r*r?r#)r$�r"�install)�	operationTr+�coder~�additional_info�rr*r5r�r�)r�&create_interactive_only_print_functionr
�entitlement_factoryrBr~rTr�ALREADY_ENABLEDrZrO�
ENABLE_FAILEDrrhr�UbuntuProError�LOG�	exception�CLIEnableDisableProgressr<rrr�ACCESS_ENABLED_TMPL�ENABLED_TMPLr.�ENABLE_REBOOT_REQUIRED_TMPLr7r��msg_code)r"ryr?r#rzrir'r>r=�interactive_only_print�ent�	ent_title�already_enabledrOr9r)�
enable_resultr r5r+�err_code�err_msg�err_infor:r|r;�_enable_one_service�s���	�
��
�	

�������
����

�
���
����r�cKs(g}g}g}g}tjdd�}|jdk}t�|�}	t|dd�}
|j}|j}|
r/|r/tj	ddd��|	t
j�zt�
|�Wn!tjtjfy\tjd	d
d�|�dt
jjt
jjd
��Ynwt|�js�t��}
|	|
j�|�d|
j|
jd
��t||||||dd�dSt|dg�}t�||�\}}t|�j}t|�j }d
}t�!||�D]3}t"|||
||||�#d�||�	}|j$r�|�|�|j%r�d
|d<q�d}|�|�|j&dur�|�|j&�q�|r�d}||7}tj'||d�}|	|j�|�dd|j|j|j(d��t�)|�}|�*�t|||||||d�|�rdSdS)z^Perform the enable action on a named entitlement.

    @return: 0 on success, 1 otherwise
    F)�_schema_versionr rur?��
--access-only�	--variant)�option1�option2zFailed to refresh contractT)�exc_info�system)rr5r�)r�r*r'r Nr�r�r)+r�JSON_SCHEMA_VERSIONrZrr��getattrr#rzr�InvalidOptionCombinationr�REFRESH_CONTRACT_ENABLEr	�refresh�ConnectivityErrorr�r��warning�append�E_REFRESH_CONTRACT_FAILURErOrBr�is_attached_and_contract_valid�ContractExpiredErrorr�rxr
�get_valid_entitlement_namesrr>r�services�order_entitlements_for_enablingr��getrr r!�*create_enable_entitlements_not_found_errorr��UAContractClient�update_activity_token)�argsr"�kwargsrkrlrmrnrjrir�r?r#rz�expired_err�names�entitlements_found�entitlements_not_foundr>r=�retryrp�err�contract_clientr:r:r;�
action_enableus��
��
���

���	
�

��
�

��
��

�
r�r2�z, r�)�options�store�+)�help�action�nargsz--assume-yes)�command�
store_true)r�r�r�z--betaz--format�cli)�defaultru)r�r��choicesr�r�)�	arguments)r��descriptionr��
help_category�
help_position�argument_groupsrG)Gru�logging�typingrrrrr�uaclientrrr	r
rrr
rrr�+uaclient.api.u.pro.services.dependencies.v1rr�%uaclient.api.u.pro.services.enable.v1rrr�-uaclient.api.u.pro.status.enabled_services.v1rr�(uaclient.api.u.pro.status.is_attached.v1r�uaclient.clir�uaclient.cli.commandsrrr�uaclient.cli.parserr�	getLogger�replace_top_level_logger_name�__name__r��bool�strr�UAConfig�AbstractProgressr<rhrxr��verify_json_format_args�assert_root�assert_attached�&_raise_enable_disable_unattached_error�intr��CLI_ROOT_ENABLE�CLI_ENABLE_DESC�
QUICKSTART�CLI_ENABLE_SERVICErZ�join�valid_services�CLI_ASSUME_YES�CLI_ENABLE_ACCESS_ONLY�CLI_ENABLE_BETA�CLI_FORMAT_DESC�CLI_ENABLE_VARIANT�enable_commandr:r:r:r;�<module>s
0�����
�,������
�\�
�����
�������
��	�

�#
���
��������
�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY