__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

Uٵg˹���SSKrSSKrSSKrSSKrSSKJr SSKJrJrJrJ	r	J
r
JrJrJ
r
 SSKJrJrJrJrJrJrJrJrJrJrJr SSKJr SSKJrJrJrJ r J!r!J"r"J#r#J$r$ SSK%J&r& SSK'J(r( SS	K)J*r*J+r+ \RX"5r-\R\"\R^"\055r1"S
S5r2"SS
\RfS9r4g)�N)�datetime)�Any�Dict�List�Optional�Set�Tuple�Type�Union)�api�apt�config�contract�event_logger�
exceptions�http�messages�snap�system�util)�_is_attached)�ApplicabilityStatus�ApplicationStatus�CanDisableFailure�CanDisableFailureReason�CanEnableFailure�CanEnableFailureReason�ContractStatus�UserFacingStatus)�
machine_token)�status_cache_file)�MessagingOperationsDict�StaticAffordancec�@�\rSrSrS\SS\R4SjrSrg)�EntitlementWithMessage�(�entitlement�
UAEntitlement�	named_msgc��XlX lg�N�r'r))�selfr'r)s   �</usr/lib/python3/dist-packages/uaclient/entitlements/base.py�__init__�EntitlementWithMessage.__init__)s��
'��"��r,N)	�__name__�
__module__�__qualname__�__firstlineno__r
r�NamedMessager/�__static_attributes__�r1r.r%r%(s$��#��/�*�#��(�(�#r1r%c
�`�\rSrSrSrSrSrSrSrSr	Sr
SrSrSr
SrSrSr\S\4Sj5r\S\\4S	j5r\\R.S\4S
j55r\\R.S\4Sj55r\S\4Sj5rS
\\\4S\\\\ RB44Sjr"\S\4Sj5r#\S\\$S44Sj5r%\S\\&S44Sj5r'\S\\&S44Sj5r(\S\\)SS44Sj5r*S\\\)S44Sjr+S\,\4Sjr-S\\\)S44Sjr.\S\\\)S44Sj5r/\S\\\)S44Sj5r0\S\S4Sj5r1S\4Sjr2\S5r3\S\44Sj5r5STS\\6RnS\S \S!\S"\\\SS4S#jjr8S$r9\S%5r:\R.S\;4S&j5r<\R.S\;4S'j5r=S\;4S(jr>S\;4S)jr?S\\\\@44S*jrAS+\BR�S\\\DS\@444S,jrES+\BR�S\4S-jrFS\4S.jrGS+\BR�S\4S/jrHS\4S0jrI\R.S+\BR�S\4S1j5rJS\\&4S2jrKS\4S3jrLS+\BR�S\\\\ RB44S4jrMS5rNS6rOS+\BR�S\\\\ RB44S7jrPSUS8\S\\\\Q44S9jjrRS+\BR�S\\\\Q44S:jrS\R.S+\BR�S\4S;j5rTS\4S<jrUS\\)S4S=jrVS+\BR�S\\\\ RB44S>jrWS\4S?jrXSUS@\SA\SS4SBjjrYS\\Z\\ RB44SCjr[S\\4SDjr]S\\^\\ RB44SEjr_\R.S\\`\\ RB44SFj5raS\\\\ RB44SGjrbS\\4SHjrcS\4SIjrdS\`4SJjreSK\\\4SL\\S\4SMjrfSUSN\\\4SO\\\4SP\S\4SQjjrgS+\BR�4SRjrhSSrig)Vr(�2NF�r8T�returnc��g)z?The lowercase name of this entitlement, in case it is a variantr;r8�r-s r.�variant_name�UAEntitlement.variant_nameSs��r1c��UR/nURUR:waURUR5 U$)z1The list of names this entitlement may be called.)�name�presentation_name�append)r-�valid_namess  r.rE�UAEntitlement.valid_namesXs;���y�y�k���!�!�T�Y�Y�.����t�5�5�6��r1c��g)z,The human readable title of this entitlementNr8r>s r.�title�UAEntitlement.title`���	
r1c��g)z&A sentence describing this entitlementNr8r>s r.�description�UAEntitlement.descriptionfrJr1c��UR(aUR$URR(aFURRS05RS05RSUR5$UR$)z/The user-facing name shown for this entitlementr'�affordances�presentedAs)�
is_variantr?�machine_token_file�
is_present�entitlement_cfg�getrBr>s r.rC�UAEntitlement.presentation_namelsi���?�?��$�$�$�
�
$�
$�
/�
/��$�$�(�(���;���]�B�'���]�D�I�I�.�
��9�9�r1�platform_checkc��g)z�Verify specific platform checks for a service.

This should only be used if the service requires custom platform checks
to check if it is available or not in the machine.
�TNr8)r-rWs  r.�verify_platform_checks�$UAEntitlement.verify_platform_checkszs��r1c�4�URnUR(atURR5VVs/sH up#SRX#R5PM" nnnSRS[R-S-/U-5nX-
nU$s snnf)z$Help information for the entitlementz
  * {}: {}�
z

)�	help_text�variants�items�formatrL�joinr�CLI_HELP_VARIANTS_HEADER)r-r^r?�variant_cls�
variant_items�variant_texts      r.�	help_info�UAEntitlement.help_info�s����N�N�	��=�=�26���1D�1D�1F��1F�-�L��#�#�L�2I�2I�J�1F�
��
 �9�9��(�;�;�;�d�B�C�� ��L�
�%�I����s�'B.c��g)Nr8r8r>s r.�static_affordances� UAEntitlement.static_affordances�s��r1c��UR$)z�
Return a list of packages that aren't compatible with the entitlement.
When we are enabling the entitlement we can directly ask the user
if those entitlements can be disabled before proceding.
Overridden in livepatch and fips
)�_incompatible_servicesr>s r.�incompatible_services�#UAEntitlement.incompatible_services�s���*�*�*r1c��UR$)z�
Return a list of packages that must be active before enabling this
service. When we are enabling the entitlement we can directly ask
the user if those entitlements can be enabled before proceding.
Overridden in ros and ros-updates.
)�_required_servicesr>s r.�required_services�UAEntitlement.required_services�s���&�&�&r1c��UR$)z�
Return a list of packages that depend on this service.
We will use that list during disable operations, where
a disable operation will also disable all of the services
required by the original service
Overriden in esm-apps and esm-infra
)�_dependent_servicesr>s r.�dependent_services� UAEntitlement.dependent_services�s���'�'�'r1c��0$r+r8r>s r.�
_get_variants�UAEntitlement._get_variants�s���	r1c��[5nUR5nURS05RS/5nUH>nURS05RS5nU(dM-URU5 M@ U$)zF
Fetch all available variants defined in the Contract Server response
r'�	overrides�selector�variant)�set�_base_entitlement_cfgrU�add)r-�valid_variantsrTr|�overrider~s      r.�_get_contract_variants�$UAEntitlement._get_contract_variants�sx������4�4�6��#�'�'�
�r�:�>�>�{�B�O�	�!�H��l�l�:�r�2�6�6�y�A�G��w��"�"�7�+�"�
�r1c���UR5nUR5nSU;aSUS0nO0n[U5HnXA;dM
XX4'M [U5S:�aU$0$)N�generic�)ryr��sorted�len)r-�service_variants�contract_variantsr�r~s     r.�_get_valid_variants�!UAEntitlement._get_valid_variants�sx���-�-�/�� �7�7�9���(�(�'�)9�)�)D�E�N��N��/�0�G��*�*:�*C��'�1�"%�^�!4�q�!8�~�@�b�@r1c�H�UR(a0$UR5$)zN
Return a list of services that are considered a variant
of the main service.
)rQr�r>s r.r_�UAEntitlement.variants�s���?�?��I��'�'�)�)r1c��UR(d0$UR5R5VVs0sHupXR:wdMX_M snn$s snnf)z_
On a variant, return the other variants of the main service.
On a non-variant, returns empty.
)rQr�r`r?)r-rB�clss   r.�other_variants�UAEntitlement.other_variants�s[������I�"�5�5�7�=�=�?�
�?�	���(�(�(�
�D�I�?�
�	
��
s�A�Ac�
�URR5HenURS:XaMU"URURUR
S9nUR
5up4U[R:XdMcUs $ g)z�
On an enabled service class, return the variant that is enabled.
Return None if no variants exist or none are enabled (e.g. access-only)
r�)�cfg�called_name�access_onlyN)	r_�valuesr?r��_called_namer��application_statusr�ENABLED)r-rdr~�status�_s     r.�enabled_variant�UAEntitlement.enabled_variant�sz�� �=�=�/�/�1�K��'�'�9�4��!��H�H� �-�-� �,�,��G�
 �2�2�4�I�F��*�2�2�2���2�r1c��g)z\
Only implemented on variant classes.
Returns True if this variant should be auto-selected.
Fr8r>s r.�variant_auto_select�!UAEntitlement.variant_auto_select	s��
r1c�b�[URR55nU(aUS$g)z�
Cannot actually set the return type because
https://github.com/python/typing/issues/266
affects xenial.

:rtype: Optional[Type["UAEntitlement"]]
rN)�listr_r�)r-r_s  r.�default_variant�UAEntitlement.default_variants+����
�
�,�,�.�/����A�;��r1c��0$r+r8r>s r.�	messaging�UAEntitlement.messaging s���	r1r�r�r��purge�
extra_argsc���U(d[R"5nXl[R"5UlX0lX@lUbXPlO/UlX l	SUl
SUlg)zMSetup UAEntitlement instance

@param config: Parsed configuration dictionary
NF)r�UAConfigr�r �get_machine_token_filerRr�r�r�r��_valid_service�_is_sources_list_updated)r-r�r�r�r�r�s      r.r/�UAEntitlement.__init__$s\����/�/�#�C���"/�"F�"F�"H���&���
��!�(�O� �D�O�'��"���(-��%r1c��[R"URR5R	UR
055$r+)�copy�deepcopyrR�entitlementsrUrBr>s r.r��#UAEntitlement._base_entitlement_cfg>s6���}�}��#�#�0�0�2�6�6�t�y�y�"�E�
�	
r1c��UR5nUR(aU(dU$[R"XRS9 U$)N)�orig_accessr~)r�rQr�apply_contract_overridesr?�r-rTs  r.rT�UAEntitlement.entitlement_cfgCs>���4�4�6�����o�"�"��)�)�'�1B�1B�	
��r1c��g)z�
The number of steps that are reported as progress while enabling
this specific entitlement that are not shared with other entitlements.
Nr8r>s r.�enable_steps�UAEntitlement.enable_stepsP���	
r1c��g)z�
The number of steps that are reported as progress while disabling
this specific entitlement that are not shared with other entitlements.
Nr8r>s r.�
disable_steps�UAEntitlement.disable_stepsXr�r1c�v�UR5nURRS05RS05RS5nUb[U5S:�aUS-
nURRS05RS05RS5nUb[U5S:�aUS-
nUR	5H.nXRUR5R5-
nM0 UR5H.nXRUR5R5-
nM0 U$)Nr'�
directives�
requiredSnapsrr��requiredPackages)	r�rTrUr��blocking_incompatible_servicesr'r�r��blocking_required_services)r-�total_steps�required_snaps�required_packages�incompatible_service�required_services      r.�calculate_total_enable_steps�*UAEntitlement.calculate_total_enable_steps`s*���'�'�)��� � �$�$�]�B�7�
�S��r�
"�
�S��
!�	�
�%�#�n�*=��*A��1��K�� � �$�$�]�B�7�
�S��r�
"�
�S�#�
$�	�
�(�S�1B�-C�a�-G��1��K�$(�$G�$G�$I� ��;�;������m�o�
�K�%J�!%� ?� ?� A���7�7������l�n�
�K�!B��r1c��UR5nUR5H%nX"UR5R5-
nM' U$r+)r��blocking_dependent_servicesr�)r-r��dependent_services   r.�calculate_total_disable_steps�+UAEntitlement.calculate_total_disable_stepszsH���(�(�*��!%�!A�!A�!C���,�T�X�X�6�D�D�F�F�K�"D��r1c��UR5(a@[RSUR5 [R
"UR5 UR5[R:Xd?S[[R[RRUR S9S94$UR#5upU[$R&:wa?S[[R([R(RUR S9S94$UR+5up4U[,R.:XaS[[R.US94$UR0(a0UR35(aS[[R454$UR6(a0UR95(dS[[R:54$UR<(dRUR>(aAS[[R@[RBRUR S954$g)z�
Report whether or not enabling is possible for the entitlement.

:return:
    (True, None) if can enable
    (False, CanEnableFailure) if can't enable
z(Updating contract on service '%s' expiryF�rH��messagerY)"�is_access_expired�LOG�debugrBr�refreshr��contract_statusr�ENTITLEDrr�NOT_ENTITLEDr�
UNENTITLEDrarHr�r�DISABLED�ALREADY_ENABLED�applicability_statusr�INAPPLICABLErn�detect_incompatible_services�INCOMPATIBLE_SERVICErr�check_required_services_active�INACTIVE_REQUIRED_SERVICES�supports_access_onlyr��ACCESS_ONLY_NOT_SUPPORTED� ENABLE_ACCESS_ONLY_NOT_SUPPORTED)r-r�r�r��detailss     r.�
can_enable�UAEntitlement.can_enable�s����!�!�#�#��I�I�@�$�)�)�L����T�X�X�&��#�#�%��)@�)@�@�� �*�7�7�$�/�/�6�6�T�Z�Z�6�H���
�!%� 7� 7� 9����!2�!;�!;�;�� �*�:�:�$�4�4�;�;�$�*�*�;�M���
�)-�(A�(A�(C�%���#6�#C�#C�C�� �*�7�7����
��%�%��0�0�2�2��$�.�C�C�����!�!��6�6�8�8��$�.�I�I�����(�(�T�-=�-=�� �*�D�D��=�=�D�D�"�j�j�E����
�r1�progressc��URSURRS55 UR5up#U(d�UcgUR[
R:Xa%URU5upEU(d
XSlSU4$OGUR[
R:Xa%URU5upeU(d
XSlSU4$OSU4$URSURRS55 UR(d.URU5(dgURU5(dgURU5nU(dgg)aEnable specific entitlement.

@return: tuple of (success, optional reason)
    (True, None) on success.
    (False, reason) otherwise. reason is only non-None if it is a
        populated CanEnableFailure reason. This may expand to
        include other types of reasons in the future.
�message_operation�pre_can_enable�FNF�
pre_enablerY)�emitr�rUr��reasonrr��handle_incompatible_servicesr�r��_enable_required_servicesr��handle_required_snaps�handle_required_packages�_perform_enable)r-r�r��fail�incompat_ret�error�req_ret�rets        r.�enable�UAEntitlement.enable�s<��	�
�
�����!3�!3�4D�!E�	
� �?�?�,��
���|�"���� 6� K� K�K�&*�&G�&G��'�#��$�#(�L� �$�;�&�$����)�D�D�E�"&�!?�!?��!I����#(�L� �$�;�&��
�d�{�"��
�
�)�4�>�>�+=�+=�l�+K�L�����-�-�h�7�7�"��0�0��:�:�"��"�"�8�,����r1c	��URRS05RS05RS5nUcg[R"5(dBUR	S[
RRSS95 [R"5 [R"5(dDUR	S[
RRS	S95 [R"S5 [R "U5 [R""S5 [(R*"SUR,R.[(R05n[(R*"SUR,R2[(R45n[R6"UU[R8S9 U(aUR;[
R<5 [?USS9HnUSn[R@"U5 M! g![RaLn[RS
US9 UR	S[
RRSS
95 SnAGNuSnAff=f![RaOn[RSUS9 [$R'[
RRSS
95 SnAGN�SnAff=f![RBak URSS5nURS5n	UR	S[
RDRUS95 [R"UU	US9 GMkf=f)z-"install snaps necessary to enable a service.r'r�r�NT�info�snapd��packagesz
snapd snapz!Failed to install snapd as a snap)�exc_infozsnap install snapd)�commandzFailed to refresh snapd snapzsnap refresh snapdr�https)�
http_proxy�https_proxy�retry_sleepsc�$�URS5$)NrB)rU)�xs r.�<lambda>�5UAEntitlement.handle_required_snaps.<locals>.<lambda>Es��Q�U�U�6�]r1)�keyrB�classicConfinementSupportF�channel)r)r�classic_confinement_support)#rTrUr�is_snapd_installedr�r�INSTALLING_PACKAGESra�
install_snapd�is_snapd_installed_as_a_snap�install_snapr�ProcessExecutionErrorr��warning�EXECUTING_COMMAND_FAILED�run_snapd_wait_cmd�refresh_snap�eventrr�validate_proxyr�r�PROXY_VALIDATION_SNAP_HTTP_URLr
�PROXY_VALIDATION_SNAP_HTTPS_URL�configure_snap_proxy�SNAP_INSTALL_RETRIESr��INSTALLING_REQUIRED_SNAPSr��
get_snap_info�SnapNotInstalledError� INSTALLING_REQUIRED_SNAP_PACKAGE)
r-r�r��err
�snap_pkg�	snap_namerrs
          r.r��#UAEntitlement.handle_required_snapss���
� � �$�$�]�B�7�
�S��r�
"�
�S��
!�	��!���&�&�(�(��M�M���4�4�;�;�W�;�M�
�
��� ��0�0�2�2��M�M���,�,�3�3�\�3�J�
�	
��!�!�'�*�	
����)�	����g�&��(�(��D�H�H�'�'��)L�)L�
�
��)�)��T�X�X�)�)�4�+O�+O�
��	
�!�!�!�#��2�2�	
�����h�@�@�A��~�3J�K�H� ��(�I�
��"�"�9�-�	L�.��w�3�3�
����?�!��L��
�
���5�5�<�<� 4�=�����
���/�/�	��K�K�6��K�C��J�J��1�1�8�8�0�9��
�
��	��8�3�3�
�.6�l�l�/��/�+�#�,�,�y�1���
�
���=�=�D�D�&�E����!�!��#�0K��
�sE�$H�I7�9K�I4�(AI/�/I4�7K�AK�K�A:M�Mc�*�URRS05RS05RS5nU(dgUVs/sHo"SPM	 nn[R"5n[	UVs/sHoUU;PM	 sn5$s snfs snf)�/install packages necessary to enable a service.r'r�r�TrB)rTrUr
�get_installed_packages_names�all)r-r��package�
package_names�installed_packages�requireds      r.�are_required_packages_installed�-UAEntitlement.are_required_packages_installed^s���
� � �$�$�]�B�7�
�S��r�
"�
�S�#�
$�	�!��8I�J�8I�W���8I�
�J� �=�=�?���<I�J�M��+�
+�M�J�
�	
��K��
Ks�B�6Bc��URRS05RS05RS5nU(dgURU5 UVs/sHo3SPM	 nn[R	SU5 UR[RRSRU5S95 [R"U5 gs snf)	r0r'r�r�TrBzInstalling packages %r� r)rTrU�_update_sources_listr�r�r�rrrarbr
�run_apt_install_command)r-r�r�r3r4s     r.r��&UAEntitlement.handle_required_packagesrs���
� � �$�$�]�B�7�
�S��r�
"�
�S�#�
$�	�!���!�!�(�+�8I�J�8I�W���8I�
�J��	�	�*�M�:�����(�(�/�/����-�0�
0�
�	
�
	�#�#�M�2���Ks�Cc�"�URRS05RS05RS5nU(dgUVs/sH!nURSS5(dMUSPM# nn[U5S:Xag[R	S	U5 S
RU5n[R[RRUS95 [R"U[RRUS95 gs snf)r0r'r�r�T�removeOnDisableFrBrzUninstalling packages %rr:r)rTrUr�r�r�rbr!rr�UNINSTALLING_PACKAGESrar
�remove_packages�UNINSTALLING_PACKAGES_FAILED)r-r�r3r4�package_names_strs     r.�!handle_removing_required_packages�/UAEntitlement.handle_removing_required_packages�s��
� � �$�$�]�B�7�
�S��r�
"�
�S�#�
$�	�!��-�
�,���{�{�,�e�4�
�G�F�O�,�	�
��}���"���	�	�,�m�<��H�H�]�3��
�
�
��*�*�1�1�;L�1�M�	
�	�����1�1�8�8�*�
9�
�	
���-
s�D�'	Dc��g)z�
Enable specific entitlement. This should be implemented by subclasses.
This method does the actual enablement, and does not check can_enable
or handle pre_enable or post_enable messaging.

@return: True on success, False otherwise.
Nr8�r-r�s  r.r��UAEntitlement._perform_enable�s��	
r1c���/nURHcnURURS9R5up4U[R
[R4;dMRURU5 Me U$)z9
:return: List of incompatible services that are enabled
�r�)rnr'r�r�rr��WARNINGrD�r-r�service�
ent_statusr�s     r.r��,UAEntitlement.blocking_incompatible_services�sy�����1�1�G�#�/�/��H�H�0�� � �"�
�J��!�)�)�!�)�)����
�
�7�#�2��
r1c�:�[UR55S:�$)z�
Check for incompatible services.

:return:
    True if there are incompatible services enabled
    False if there are no incompatible services enabled
r)r�r�r>s r.r��*UAEntitlement.detect_incompatible_services�s���4�6�6�8�9�A�=�=r1c��[R"URRSS9nUR5H�nUR	UR5n[
RRURURS9nU(aSU4s $URS[
RRURS95 URU5upgU(aM�Xg(aUR4s $S4s $ g)	a�
Prompt user when incompatible services are found during enable.

When enabling a service, we may find that there is an incompatible
service already enable. In that situation, we can ask the user
if the incompatible service should be disabled before proceeding.
There are also different ways to configure that behavior:

We can disable removing incompatible service during enable by
adding the following lines into uaclient.conf:

features:
  block_disable_on_enable: true
z features.block_disable_on_enable)r�
path_to_value)�service_being_enabledr�Fr�rMNrY)
r�is_config_value_truer�r�r'r�#E_INCOMPATIBLE_SERVICE_STOPS_ENABLErarHr��DISABLING_INCOMPATIBLE_SERVICE�disabler�)r-r��cfg_block_disable_on_enablerM�ent�e_msgrr�s        r.r��*UAEntitlement.handle_incompatible_services�s���$'+�&?�&?��8�8�<�<�<�'
�#��:�:�<�G��%�%�d�h�h�/�C��@�@�G�G�&*�j�j�%(�Y�Y�H��E�
+��e�|�#��M�M���7�7�>�>��I�I�?��
����H�-�I�C��3��T�T�\�\�<�<�t�<�<�)=�,r1c�:�[UR55S:H$)z�
Check if all required services are active

:return:
    True if all required services are active
    False is at least one of the required services is disabled
r)r�r�r>s r.r��,UAEntitlement.check_required_services_actives���4�2�2�4�5��:�:r1c���/nURHenURUR5R5up4U[R
[R4;dMTURU5 Mg U$)z6
:return: List of required services that are disabled
)rrr'r�r�rr�rKrDrLs     r.r��(UAEntitlement.blocking_required_servicessl�����-�-�G�#�/�/����9�L�L�N�M�J��!�)�)�!�)�)�"���
�
�7�#�
.��
r1c��UR5H�nURURS9nURS[R
R
URS95 URU5upEU(aMoSnU(aEUR(a4URR(aSURR-n[RR
XcRS9nXG4s $ g)a
Prompt user when required services are found during enable.

When enabling a service, we may find that there are required services
that must be enabled first. In that situation, we can ask the user
if the required service should be enabled before proceeding.
rJrrUr;r])r�rMrY)r�r'r�r�r�ENABLING_REQUIRED_SERVICErarHrr��msg�ERROR_ENABLING_REQUIRED_SERVICE)r-r�r�r[rr��	error_msgrds        r.r��'UAEntitlement._enable_required_servicess���!%� ?� ?� A��"�.�.��H�H�/��C�
�M�M���2�2�9�9�#�)�)�9�L�
��
�
�8�,�I�C��3��	��D�L�L�T�\�\�-=�-=� $�t�|�|�'7�'7� 7�I��>�>�E�E�#�Y�Y�F����x��#!B�&r1�ignore_dependent_servicesc��UR5up#U[R:Xa?S[[R
[R
RURS9S94$UR5upCUR(aU[R:Xa?S[[R[RRURS9S94$UR(a7U(d0UR!5(aS[[R"54$UR$(dRUR&(aAS[[R([R*RURS954$g)z�Report whether or not disabling is possible for the entitlement.

:return:
    (True, None) if can disable
    (False, CanDisableFailure) if can't disable
Fr�r�rY)r�rr�rr�ALREADY_DISABLEDrrarHr�rTrr��NOT_APPLICABLE�CANNOT_DISABLE_NOT_APPLICABLErv�detect_dependent_services�ACTIVE_DEPENDENT_SERVICES�supports_purger��PURGE_NOT_SUPPORTED�DISABLE_PURGE_NOT_SUPPORTED)r-rhr�r�r�s     r.�can_disable�UAEntitlement.can_disable=s]��!%� 7� 7� 9����!2�!;�!;�;��!�+�<�<�$�5�5�<�<�4�:�:�<�N���
�#'�";�";�"=����$�$�#�':�'G�'G�G��!�+�:�:�$�B�B�I�I�"�j�j�J����
��"�"�+D��-�-�/�/��%�/�I�I�����"�"�t�z�z��!�+�?�?��8�8�?�?�"�j�j�@����
�r1c���URSURRS55 UR5up#U(dKUcgUR[
R:Xa%URU5upEU(d
XSlSU4$OSU4$URU5(dgUR5(dgURSURRS55 g)aaDisable specific entitlement

@param silent: Boolean set True to silence print/log of messages

@return: tuple of (success, optional reason)
    (True, None) on success.
    (False, reason) otherwise. reason is only non-None if it is a
        populated CanDisableFailure reason. This may expand to
        include other types of reasons in the future.
r��pre_disabler�F�post_disablerY)r�r�rUrrr�rrn�_disable_dependent_servicesr��_perform_disablerD)r-r�rrr�rrds      r.rY�UAEntitlement.disable|s���	�
�
�)�4�>�>�+=�+=�m�+L�M� �,�,�.�����|�"����*�D�D�E� �;�;�H�E����#&�L� �$�;�&��
�d�{�"��$�$�X�.�.���5�5�7�7���
�
�)�4�>�>�+=�+=�n�+M�N�r1c��g)a,
Disable specific entitlement. This should be implemented by subclasses.
This method does the actual disable, and does not check can_disable
or handle pre_disable or post_disable messaging.

@param silent: Boolean set True to silence print/log of messages

@return: True on success, False otherwise.
Nr8rGs  r.rx�UAEntitlement._perform_disable�s��	
r1c�:�[UR55S:�$)z�
Check for depedent services.

:return:
    True if there are dependent services enabled
    False if there are no dependent services enabled
r)r�r�r>s r.rm�'UAEntitlement.detect_dependent_services�s���4�3�3�5�6��:�:r1c���/nURHLnU"UR5R5up4U[R:XdM;URU5 MN U$)zW
Return list of depedent services that must be disabled
before disabling this service.
)rvr�r�rr�rD)r-�blocking�dependent_service_clsrNr�s     r.r��)UAEntitlement.blocking_dependent_services�s^��
��%)�%<�%<�!�1����� � �"�
�J��.�6�6�6���� 5�6�&=��r1c���UR5H�nU"URS9nURS[RRURS95 URU5upEU(aMfSnU(aEUR(a4URR(aSURR-n[RRXcRS9nSU4s $ g)	a9
Disable dependent services

When performing a disable operation, we might have
other services that depend on the original services.
If that is true, we will alert the user about this
and prompt for confirmation to disable these services
as well.

@param silent: Boolean set True to silence print/log of messages
rJr)r�r;r])r�r�FrY)r�r�r�r�DISABLING_DEPENDENT_SERVICErarHrYr�rd�"FAILED_DISABLING_DEPENDENT_SERVICE)r-r�r�r[rr�rfrds        r.rw�)UAEntitlement._disable_dependent_services�s���&*�%E�%E�%G�!�'�D�H�H�5�C��M�M���4�4�;�;�%(�Y�Y�<��
����H�-�I�C��3��	��D�L�L�T�\�\�-=�-=� $�t�|�|�'7�'7� 7�I��A�A�H�H�#�i�i�I����c�z�!�'&H�*r1c��g)z=Check if system needs to be rebooted because of this service.Fr8r>s r.�_check_for_reboot�UAEntitlement._check_for_reboot�s��r1�	operation�silentc��UR5(a9U(d1[R[RRUS95 ggg)z�Check if user should be alerted that a reboot must be performed.

@param operation: The operation being executed.
@param silent: Boolean set True to silence print/log of messages
)r�N)r�r!rr�ENABLE_REBOOT_REQUIRED_TMPLra)r-r�r�s   r.�_check_for_reboot_msg�#UAEntitlement._check_for_reboot_msg�sE���!�!�#�#�F��J�J��4�4�;�;�'�<��
�-3�#r1c���URnU(d [R[R4$UR
H%up#nU"5U:wdM[RU4s $ USRS05nURSS5nUR(a�Ub�[R"5U;aq[R"U5n[R[RRUR[R"5SR!U5S94$URSS5nUR"(a{Ubx[R$"5R&U;aU[R[R(RUR[R$"5R*S94$[R,"5n	URS	S5n
URS
S5nUR.(aeU
bbU	R0U
;aR[R[R2RURU	R4SR!U
5S94$UR6(a�U(a�U	R8b�U	R:b�[R<RURU	R4US9nUR?S
5up�[AU
5n[AU5nU	R8U:a[RU4$U	R8U:Xa"U	R:U:a[RU4$URS05nURIU5unnU(d[RU4$[RS4$![Ba+ [DRGSU5 [RU4s$f=f)a�Check all contract affordances to vet current platform

Affordances are a list of support constraints for the entitlement.
Examples include a list of supported series, architectures for kernel
revisions.

:return:
    tuple of (ApplicabilityStatus, NamedMessage). APPLICABLE if
    platform passes all defined affordances, INAPPLICABLE if it doesn't
    meet all of the provided constraints.
r'rO�
architecturesNz, )rH�arch�supported_arches�series)rHr��
kernelFlavors�minKernelVersion)rH�kernel�supported_kernels)rHr��
min_kernel�.z$Could not parse minKernelVersion: %s�platformChecks)%rTr�
APPLICABLEr�"NO_ENTITLEMENT_AFFORDANCES_CHECKEDrjr�rU�affordance_check_archr�
get_dpkg_archr�deduplicate_arches�INAPPLICABLE_ARCHrarHrb�affordance_check_series�get_release_infor��INAPPLICABLE_SERIES�pretty_version�get_kernel_info�affordance_check_kernel_flavor�flavor�INAPPLICABLE_KERNEL�
uname_release�#affordance_check_kernel_min_version�major�minor�INAPPLICABLE_KERNEL_VER�split�int�
ValueErrorr�rrZ)r-rT�
error_message�functor�expected_resultrO�affordance_arches�deduplicated_arches�affordance_series�kernel_info�affordance_kernels�affordance_min_kernel�invalid_msg�kernel_major�kernel_minor�min_kern_major�min_kern_minor�affordances_platform_checkrr�s                    r.r��"UAEntitlement.applicability_statussy���.�.���#�.�.��;�;��
�8<�7N�7N�3�M�O��y�O�+�*�7�7��F�F�8O�&�m�4�8�8���K��'�O�O�O�T�B���&�&�!�-��$�$�&�.?�?�"&�"9�"9�:K�"L��#�0�0��*�*�1�1��*�*��-�-�/�%)�Y�Y�/B�%C�2���
�(�O�O�H�d�;���(�(�!�-��'�'�)�0�0�8I�I�$�0�0��,�,�3�3��*�*�!�2�2�4�C�C�4���
��,�,�.��(�_�_�_�d�C�� +���0B�D� I���/�/�"�.��!�!�);�;�'�4�4��0�0�7�7�"�j�j�*�8�8�*.�)�)�4F�*G�8����
�4�4�%��!�!�-��!�!�-�"�:�:�A�A��j�j�"�0�0�0�B��K�
	
G�-B�-H�-H��-M�*��!$�\�!2��!$�\�!2��� � �>�1�*�7�7��D�D��!�!�^�3��%�%��6�*�7�7��D�D�%0�_�_�5E�r�%J�"��1�1�2L�M���V��'�4�4�f�=�=�"�-�-�t�3�3��)�
G����:�)��,�8�8�+�F�F�
G�s�!)N/�/2O$�#O$c��[UR5R(d[R$UR
nU(a)USR
S5(a[R$[R$)z=Return whether the user is entitled to the entitlement or notr'�entitled)rr��is_attachedrr�rTrUr�r�s  r.r��UAEntitlement.contract_statusms[���D�H�H�%�1�1�!�,�,�,��.�.����}�=�A�A�*�M�M�!�*�*�*��(�(�(r1c���UR5upU[R:wa[RU4$UR
nU(d7[R[RRURS94$USRSS5SLa7[R[RRURS94$UR5upEU[R:Xa[RU4$U[R :Xa[R U4$UR#5upgU(a[R U4$[R$U4$)z4Return (user-facing status, details) for entitlementr�r'r�F)r�rr�rr�rT�UNAVAILABLEr�SERVICE_NOT_ENTITLEDrarHrUr�rr��INACTIVErK�enabled_warning_status�ACTIVE)r-�
applicabilityr�rTr��explanationr�warn_msgs        r.�user_facing_status� UAEntitlement.user_facing_statusvsE��"&�!:�!:�!<��
��/�:�:�:�#�0�0�'�9�9��.�.��� �,�,��-�-�4�4�4�:�:�4�F��
��]�
+�
/�
/�
�E�
B�e�
K� �,�,��-�-�4�4�4�:�:�4�F��
�
+/�*A�*A�*C�'���!2�!;�!;�;�#�,�,�k�9�9�
�#4�#<�#<�
<�#�+�+�[�8�8� �7�7�9����#�+�+�X�5�5��&�&��3�3r1c��g)z{
The current status of application of this entitlement

:return:
    A tuple of (ApplicationStatus, human-friendly reason)
Nr8r>s r.r�� UAEntitlement.application_status�s��	
r1c��g)z�
If the entitlment is enabled, are there any warnings?
The message is displayed as a Warning Notice in status output

:return:
    A tuple of (warning bool, human-friendly reason)
r�r8r>s r.r��$UAEntitlement.enabled_warning_status�s��r1c��gr+r8r>s r.�status_description_override�)UAEntitlement.status_description_override�s��r1c��URRS5nU(dg[R"US5nU[R"5:�agg)z<Return entitlement access info as stale and needing refresh.�expiresFz%Y-%m-%dT%H:%M:%S.%fZT)rTrUr�strptime�utcnow)r-�
expire_str�expirys   r.r��UAEntitlement.is_access_expired�sH���)�)�-�-�i�8�
����"�"�:�/F�G���X�_�_�&�&��r1c�\�[R"5nUc[R$UR	S/5nUH]nUR	S5UR
:XdM$UR	S5nUS:Xa[Rs $[Rs $ [R$)z6Check on the state of application on the status cache.�servicesrBr��enabled)r!�readrr�rUrBr�)r-�status_cache�services_status_listrM�service_statuss     r.�"_check_application_status_on_cache�0UAEntitlement._check_application_status_on_cache�s���(�-�-�/����$�-�-�-�+�/�/�
�B�?��+�G��{�{�6�"�d�i�i�/�!(���X�!6��!�Y�.�,�4�4�4�,�5�5�5�,�!�)�)�)r1�obligations�
resourceTokenc�H�[URS5=(a U5$)N�enableByDefault)�boolrU)r-r�r�s   r.�_should_enable_by_default�'UAEntitlement._should_enable_by_default�s���K�O�O�$5�6�H�=�I�Ir1r��deltas�allow_enablec���U(dgURS05nURS05n[R"5n[U[R
:H5nU(dGU(a[R"U5 USnU(aSU;aUSS[R
4;nU(GaOU(aU(aUR5nOUR5up�U[R:wGaUR5up�U
(a[RSUR5 UR!["R$"55 [&R[(R*R-URS95 gU(aUR.OSn[R1S	URU5 [&R[(R2R-URS95 gURS
5n
U
(dURS
5n
URS05nUR5X�5nUR75unn	U(GaU(a�U(a�[(R8R-URS9n[&RU[:R<S
9 UR?["R$"55 [&R[(R@R-URBS95 g[(RDR-URS9n[&RU[:R<S
9 gg)a%Process 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.
:raise: UbuntuProError when auto-enable fails unexpectedly.
Tr'r�r�Fz3Disabling %s after refresh transition to unentitledrUr;zDCannot disable %s after refresh transition to unentitled.
Reason: %sr�r��rB)�	file_typer�)#rUr!r�r�r�DROPPED_KEYrr�r�r�rr�rrr�rrBrYr�ProgressWrapperr!r�DISABLE_DURING_CONTRACT_REFRESHra�
message_valuer�)UNABLE_TO_DISABLE_DURING_CONTRACT_REFRESHr�r��ENABLE_BY_DEFAULT_TMPL�sys�stderrr�ENABLED_TMPLrH�ENABLE_BY_DEFAULT_MANUAL_TMPL)r-r�r�r��delta_entitlement�delta_directivesr��transition_to_unentitledr�r�rrr��fail_msgr��delta_obligations�enable_by_defaultr�rds                  r.�process_contract_deltas�%UAEntitlement.process_contract_deltas�s���&��"�J�J�}�b�9��,�0�0��r�B��(�-�-�/��#'�(9�T�=M�=M�(M�#N� �'� ��1�1�&�9�$*�=�$9�!��z�->�>�+<�Z�+H���$�$�M�,�(�$��L�%)�%L�%L�%N�"�(,�(?�(?�(A�%�"�!�%6�%?�%?�?�$(�$4�$4�$6�!����H�H�M��	�	���L�L��!4�!4�!6�7��J�J� �@�@�G�G�$(�I�I�H���&�6:�t�1�1�r�H��K�K�2��	�	� �	��J�J� �J�J�Q�Q�$(�I�I�R���
�#����8�
��"�J�J��7�M�-�1�1�-��D�� �:�:��
�����)�
�
�A��+���5�5�<�<�$�)�)�<�L���
�
�3�#�*�*�
�5����C�/�/�1�2��
�
�8�0�0�7�7�d�j�j�7�I�J��	�<�<�C�C����D����
�
�3�#�*�*�
�5��r1c���UR(agURS[RR	SS95 [
R"[
R"55 SUlg)Nrzstandard Ubuntur�T)r�r�r�APT_UPDATING_LISTrar
�update_sources_list�get_system_sources_filerGs  r.r;�"UAEntitlement._update_sources_list8sU���(�(���
�
��H�.�.�5�5�;L�5�M�	
�	���� ;� ;� =�>�(,��%r1)r�r�r�r�r�r�rRr�)Nr;FFN)F)jr2r3r4r5rB�help_doc_urlr�ror^rmrqrur�r�r�r�rQ�property�strr?rrE�abc�abstractmethodrHrLrCrrr	r�rrr6rZrgr#rjr%rnrrr
rvryrr�r�r_r�r�r�r�r"r�rr�r/r�rTr�r�r�r�r�rr�rr�rrr�r7r�rDr�r�r�r�r�r�r�rrrrYrxrmr�rwr�r�rr�rr�rr�rr�r�r�r�r�r�rr;r7r8r1r.r(r(2sx���D��L�!���N��I� ������ ��"��*.�'�%)�"��J�
��c������T�#�Y��������
�s�
���
�����
�S�
���
���3�����"�3��8�n��	�t�X�h�3�3�4�4�	5����3����*��E�*:�C�*?�$@�����+�u�-C�S�-H�'I�+��+��'�5�)?��)D�#E�'��'��(�E�$��*?��*D�$E�(��(��t�C��o�)>�$>�?��
��C��
�
A�T�#�t�O�/D�*D�%E�
A��*�$�s�D��$9�9�:�*��*��
��S�$��*?�%?� @�
��
����/�!:����$�T��������2����
*.��!��*.�
.�
�f�o�o�
&�.��.��	.�
�.��T�#�Y�'�
.�
�.�4
�
�
��
�	���
�c�
��
�	���
�s�
��
��c��4�s��F�E�$��1A�(B�"B�C�F�T;��%�%�;�
�t�U�4�!1�1�2�2�	3�;�zU�c�.A�.A�U�d�U�n
��
�(��1D�1D����4#�4�#�J	���
��(;�(;�
��
��
���5K�0L��">�d�>�,��%�%�,�
�t�X�h�3�3�4�4�	5�,�\;����%�%��
�t�X�h�3�3�4�4�	5��B16�=�)-�=�	�t�X�/�0�0�	1�=�~(��+�+�(�	�t�X�/�0�0�	1�(�T	���

��)<�)<�

��

��

�;�4�;�
�T�$��2G�-H�
�#��+�+�#�	�t�X�h�3�3�4�4�	5�#�J�4��
.3�
��
�&*�
�	
�
�g4�	�"�H�X�-B�-B�$C�C�	D�g4�R)��)�4�	���(�*?�*?�!@�@�	A�4�B	���	
�	� �(�8�+@�+@�"A�A�	B�	
��	
�
�	�t�X�h�3�3�4�4�	5�
��	�#���
	�4�	�*�4E�*�(J���S��>�J�:B�3�-�J�	
�J�#�	^��#�s�(�^�^��S�#�X��^��	^�

�^�@-�S�-@�-@�-r1r()�	metaclass)5r
r��loggingr�r�typingrrrrrr	r
r�uaclientrr
rrrrrrrrr�(uaclient.api.u.pro.status.is_attached.v1r�(uaclient.entitlements.entitlement_statusrrrrrrrr�uaclient.filesr �uaclient.files.state_filesr!�uaclient.typesr"r#�get_event_loggerr!�	getLogger�replace_top_level_logger_namer2r�r%�ABCMetar(r8r1r.�<module>rs���
���
��E�E�E�����B�	�	�	�)�8�D��%�%�'��
����:�:�8�D�E��#�#�M-�c�k�k�M-r1

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 10.54 KB 0644
anbox.cpython-313.pyc File 4.5 KB 0644
base.cpython-313.pyc File 52.53 KB 0644
cc.cpython-313.pyc File 1.67 KB 0644
cis.cpython-313.pyc File 2.21 KB 0644
entitlement_status.cpython-313.pyc File 5.94 KB 0644
esm.cpython-313.pyc File 6.54 KB 0644
fips.cpython-313.pyc File 27.2 KB 0644
landscape.cpython-313.pyc File 6.84 KB 0644
livepatch.cpython-313.pyc File 17.61 KB 0644
realtime.cpython-313.pyc File 10.54 KB 0644
repo.cpython-313.pyc File 30.89 KB 0644
ros.cpython-313.pyc File 2.93 KB 0644
Filemanager