CasperSecurity

Current Path : /usr/lib/python3/dist-packages/uaclient/files/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/uaclient/files/__pycache__/notices.cpython-310.pyc

o

�K�i�!�@s�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
e�e
�e��Ze
��Zedgd��ZGdd	�d	ee�ZGd
d�d�Zdadd
�Zdeddfdd�Zdeddfdd�Zdeefdd�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)&�Notice�contract_expired�5T)rrr
r�reboot_required�10FzSystem reboot required�enable_reboot_required�11�reboot_script_failed�12�fips_reboot_required�20�fips_system_reboot_required�21�fips_install_out_of_date�22�fips_disable_reboot_required�23�fips_proc_file_error�24�fips_manual_disable_url�25�wrong_fips_metapackage_on_cloud�lp_lts_reboot_required�30�operation_in_progress�60z"Operation in progress: {operation}�auto_attach_retry_full_notice�70�auto_attach_total_failure�71�limited_to_release�80N)�__name__�
__module__�__qualname__r
r�CONTRACT_EXPIRED�REBOOT_REQUIRED�ENABLE_REBOOT_REQUIRED_TMPL�ENABLE_REBOOT_REQUIRED�REBOOT_SCRIPT_FAILED�FIPS_REBOOT_REQUIRED_MSG�FIPS_REBOOT_REQUIRED�FIPS_SYSTEM_REBOOT_REQUIRED�FIPS_INSTALL_OUT_OF_DATE�FIPS_DISABLE_REBOOT_REQUIRED�FIPS_PROC_FILE_ERROR�tmpl_msg�NOTICE_FIPS_MANUAL_DISABLE_URL�FIPS_MANUAL_DISABLE_URL�&NOTICE_WRONG_FIPS_METAPACKAGE_ON_CLOUD�WRONG_FIPS_METAPACKAGE_ON_CLOUD�LIVEPATCH_LTS_REBOOT_REQUIRED�OPERATION_IN_PROGRESS�AUTO_ATTACH_RETRY_NOTICE�AUTO_ATTACH_RETRY_FULL_NOTICE�&AUTO_ATTACH_RETRY_TOTAL_FAILURE_NOTICE�AUTO_ATTACH_RETRY_TOTAL_FAILURE�LIMITED_TO_RELEASE�rIrI�8/usr/lib/python3/dist-packages/uaclient/files/notices.pyrs����������������
�rc@s|eZdZdedefdd�Zdefdd�Zdedeefd	d
�Zdedede	fdd
�Z
dedefdd�Zdeefdd�ZdS)�NoticesManager�notice_details�descriptioncCs^t��st�d|jj�dS|jjrtjntj	}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�formatrr�
write_file�os�path�join)�selfrLrM�	directory�filenamerIrIrJ�addts"�����zNoticesManager.addcCs\t��st�d|jj�dS|jjrtjntj	}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 userNrN)r	rOrPrQrRrr
rrSrTrUrr�ensure_file_absentrWrXrY)rZrLr[r\rIrIrJ�remove�s����zNoticesManager.remover[�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|�qSrI)rWrX�isfilerY�_is_valid_notice_file)�.0�	file_name�r[rZrIrJ�
<listcomp>�s�
��z9NoticesManager._get_notice_file_names.<locals>.<listcomp>)rW�listdir)rZr[rIrerJ�_get_notice_file_names�s�z%NoticesManager._get_notice_file_namesrdcs$|tjk��fdd�tD�}||vS)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)rN)r
rUrr)rc�n��is_permanent_dirrIrJ�	<setcomp>�s

�z7NoticesManager._is_valid_notice_file.<locals>.<setcomp>)rrSr)rZr[rd�valid_file_namesrIrjrJrb�s


�z$NoticesManager._is_valid_notice_filecCs<|�d�\}}tD]}|j|kr|j|kr|jjSq	dS)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rRr)rZrdrr�noticerIrIrJ�_get_default_message�s�z#NoticesManager._get_default_messagec
Cs�tjtjf}g}|D]B}tj�|�sq
|�|�}|D]1}zt�tj�	||��}Wnt
y8t�d|�Yqw|rA|�
|�q|�|�}|�
|�qq
|��|S)zdGets all the notice files currently saved.

        :returns: List of notice file contents.
        zPermission error while reading )rrSrTrWrX�existsrhr�	load_filerY�PermissionErrorrPrQ�appendrr�sort)rZ�notice_directories�notices�notice_directory�notice_file_names�notice_file_name�notice_file_contents�default_messagerIrIrJ�list�s8�
�����zNoticesManager.listN)
r/r0r1r�strr]r_rrh�boolrbrrrrIrIrIrJrKss�
�
rKcCstdurt�atS�N)�_notice_clsrKrIrIrIrJ�
get_notice�sr�rLr`cKs(t�}|jjdi|��}|�||�dS)NrI)r�rrUr])rL�kwargsrqrMrIrIrJr]�sr]cCst�}|�|�dSr�)r�r_)rLrqrIrIrJr_sr_cCst�}|��Sr�)r�r)rqrIrIrJr	sr)�loggingrW�collectionsr�enumr�typingr�uaclientrrrrr	�	getLogger�replace_top_level_logger_namer/rP�get_event_logger�eventr
rrKr�r�r]r_r�rrIrIrIrJ�<module>s&�c
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