HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/uaclient/files/__pycache__/notices.cpython-38.pyc
U

��Jh�!�@s�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
e�e
�e��Ze
��Zedddd	d
g�ZGdd�dee�ZGd
d�d�Zdadd�Zedd�dd�Zedd�dd�Zeed�dd�ZdS)�N)�
namedtuple)�Enum)�List)�defaults�event_logger�messages�system�util�NoticeFileDetails�order_id�label�is_permanent�messagec@s*eZdZedddejd�Zeddddd�Zed	d
dejd�Zedddej	d�Z	ed
ddej
d�Zedddejd�Zedddej
d�Z
edddejd�Zedddejjd�Zedddejd�Zedddejd�Zedddejd�Zeddddd�Zedd dejd�Zed!d"dejd�Zed#d$dejd�Zd%S)&�NoticeZcontract_expired�5T)rrr
rZreboot_requiredZ10FzSystem reboot requiredZenable_reboot_requiredZ11Zreboot_script_failedZ12Zfips_reboot_requiredZ20Zfips_system_reboot_requiredZ21Zfips_install_out_of_dateZ22Zfips_disable_reboot_requiredZ23Zfips_proc_file_errorZ24Zfips_manual_disable_urlZ25Zwrong_fips_metapackage_on_cloudZlp_lts_reboot_requiredZ30Zoperation_in_progressZ60z"Operation in progress: {operation}Zauto_attach_retry_full_noticeZ70Zauto_attach_total_failureZ71Zlimited_to_releaseZ80N)�__name__�
__module__�__qualname__r
rZCONTRACT_EXPIREDZREBOOT_REQUIREDZENABLE_REBOOT_REQUIRED_TMPLZENABLE_REBOOT_REQUIREDZREBOOT_SCRIPT_FAILEDZFIPS_REBOOT_REQUIRED_MSGZFIPS_REBOOT_REQUIREDZFIPS_SYSTEM_REBOOT_REQUIREDZFIPS_INSTALL_OUT_OF_DATEZFIPS_DISABLE_REBOOT_REQUIREDZFIPS_PROC_FILE_ERRORZtmpl_msgZNOTICE_FIPS_MANUAL_DISABLE_URLZFIPS_MANUAL_DISABLE_URLZ&NOTICE_WRONG_FIPS_METAPACKAGE_ON_CLOUDZWRONG_FIPS_METAPACKAGE_ON_CLOUDZLIVEPATCH_LTS_REBOOT_REQUIREDZOPERATION_IN_PROGRESSZAUTO_ATTACH_RETRY_NOTICEZAUTO_ATTACH_RETRY_FULL_NOTICEZ&AUTO_ATTACH_RETRY_TOTAL_FAILURE_NOTICEZAUTO_ATTACH_RETRY_TOTAL_FAILUREZLIMITED_TO_RELEASE�rr�8/usr/lib/python3/dist-packages/uaclient/files/notices.pyrs�����������������rc@sreZdZeed�dd�Zed�dd�Zeeed�dd	�Zeee	d
�dd�Z
eed
�dd�Zeed�dd�ZdS)�NoticesManager)�notice_details�descriptioncCs^t��st�d|jj�dS|jjr*tjntj	}d�
|jj|jj�}t�
tj�||�|�dS)z�Adds a notice file. If the notice is found,
        it overwrites it.

        :param notice_details: Holds details concerning the notice file.
        :param description: The content to be written to the notice file.
        z.NoticesManager.add(%s) called as non-root userN�{}-{})r	�we_are_currently_root�LOG�warning�valuerr
r�NOTICES_PERMANENT_DIRECTORY�NOTICES_TEMPORARY_DIRECTORY�formatrrZ
write_file�os�path�join)�selfrr�	directory�filenamerrr�addts$�����zNoticesManager.add)rcCs\t��st�d|jj�dS|jjr*tjntj	}d�
|jj|jj�}t�
tj�||��dS)ziDeletes a notice file.

        :param notice_details: Holds details concerning the notice file.
        z1NoticesManager.remove(%s) called as non-root userNr)r	rrrrrr
rrrr rrZensure_file_absentr!r"r#)r$rr%r&rrr�remove�s����zNoticesManager.remove)r%�returncs��fdd�t���D�S)z�Gets the list of notice file names in the given directory.

        :param directory: The directory to search for notice files.
        :returns: List of notice file names.
        cs2g|]*}tj�tj��|��r���|�r|�qSr)r!r"�isfiler#�_is_valid_notice_file)�.0�	file_name�r%r$rr�
<listcomp>�s�z9NoticesManager._get_notice_file_names.<locals>.<listcomp>)r!�listdir)r$r%rr.r�_get_notice_file_names�s�z%NoticesManager._get_notice_file_names)r%r-r)cs$|tjk��fdd�tD�}||kS)z�Checks if the notice file is valid.

        :param file_name: The name of the notice file.
        :returns: True if the file is valid, False otherwise.
        cs&h|]}|j�krd�|j|j��qS)r)r
r rr)r,�n�Zis_permanent_dirrr�	<setcomp>�s
�z7NoticesManager._is_valid_notice_file.<locals>.<setcomp>)rrr)r$r%r-Zvalid_file_namesrr3rr+�s


�z$NoticesManager._is_valid_notice_file)r-r)cCs<|�d�\}}tD]$}|j|kr|j|kr|jjSqdS)z�Gets the default message for a notice file.

        :param file_name: The name of the notice file.
        :returns: The default message defined in the enum.
        �-�)�splitrrrrr)r$r-rr�noticerrr�_get_default_message�s
z#NoticesManager._get_default_message�r)c
Cs�tjtjf}g}|D]�}tj�|�s&q|�|�}|D]h}zt�tj�	||��}Wn&t
k
rvt�d|�Yq4YnX|r�|�
|�q4|�|�}|�
|�q4q|��|S)zdGets all the notice files currently saved.

        :returns: List of notice file contents.
        zPermission error while reading )rrrr!r"�existsr1rZ	load_filer#�PermissionErrorrr�appendr9�sort)r$Znotice_directoriesZnoticesZnotice_directoryZnotice_file_namesZnotice_file_nameZnotice_file_contentsZdefault_messagerrr�list�s4�
��
�zNoticesManager.listN)
rrrr�strr'r(rr1�boolr+r9r?rrrrrss�
rcCstdkrt�atS�N)�_notice_clsrrrrr�
get_notice�srD)rr)cKs$t�}|jjf|�}|�||�dSrB)rDrr r')r�kwargsr8rrrrr'�sr'cCst�}|�|�dSrB)rDr()rr8rrrr(sr(r:cCst�}|��SrB)rDr?)r8rrrr?	sr?)Zloggingr!�collectionsr�enumr�typingrZuaclientrrrrr	Z	getLoggerZreplace_top_level_logger_namerrZget_event_loggerZeventr
rrrCrDr'r(r@r?rrrr�<module>s&
�c