U
    M[‚^Ž  ã                   @   sˆ   d dl mZ d dlmZmZmZ zd dlmZmZm	Z	m
Z
 W n ek
rP   Y nX G dd„ dejƒZG dd„ deƒZG dd	„ d	eƒZd
S )é    )Úrepo)ÚaptÚstatusÚutil)ÚDictÚListÚSetÚTuplec                       s~   e Zd ZdZeddhƒZdhdhdheƒ dhdœZed	d
œdd„ƒZ	dd
œ‡ fdd„Z
deedœdd„Zdd
œdd„Z‡  ZS )ÚFIPSCommonEntitlementié  zfips-initramfsz
linux-fipszlibssl1.0.0-hmaczopenssh-client-hmaczopenssh-server-hmaczstrongswan-hmac)zlibssl1.0.0zopenssh-clientzopenssh-serverZopensslZ
strongswanz	List[str])Úreturnc                 C   sF   t | jƒ}t ¡ }| j ¡ D ]$\}}||kr| |¡ | |¡ q|S )N)ÚlistÚfips_required_packagesr   Zget_installed_packagesÚfips_packagesÚitemsÚappendÚextend)ÚselfÚpackagesZinstalled_packagesÚpkg_nameZ
extra_pkgs© r   ú</usr/lib/python3/dist-packages/uaclient/entitlements/fips.pyr      s    

zFIPSCommonEntitlement.packagesz$Tuple[status.ApplicationStatus, str]c                    sL   t ƒ  ¡ \}}|tjjkr"||fS t ¡ d }| d¡r@||fS tjjdfS )NZkernelz-fipszReboot to FIPS kernel required)ÚsuperÚapplication_statusr   ZApplicationStatusZENABLEDr   Zget_platform_infoÚendswith)r   Zsuper_statusZ	super_msgZrunning_kernel©Ú	__class__r   r   r   !   s    
þz(FIPSCommonEntitlement.application_statusF)Úsilentr   c                 C   s   |st d | j¡ƒ dS )z@FIPS cannot be disabled, so simply display a message to the userz Warning: no option to disable {}F)ÚprintÚformatÚtitle)r   r   r   r   r   Údisable-   s    zFIPSCommonEntitlement.disableNc                 C   s   dS )z<FIPS can't be cleaned up automatically, so don't do anythingNr   )r   r   r   r   Ú_cleanup3   s    zFIPSCommonEntitlement._cleanup)F)Ú__name__Ú
__module__Ú__qualname__Zrepo_pin_priorityÚ	frozensetr   Úsetr   Úpropertyr   r   Úboolr    r!   Ú__classcell__r   r   r   r   r
      s   û	r
   c                   @   s<   e Zd ZdZdZdZdZddgiZdZdZ	d	e
jd
ffZdS )ÚFIPSEntitlementzhttps://ubuntu.com/fipsZfipsZFIPSzNIST-certified FIPS modulesÚpost_enablez,A reboot is required to complete the installZ
UbuntuFIPSzubuntu-fips-keyring.gpgz"Cannot install FIPS on a containerFN)r"   r#   r$   Zhelp_doc_urlÚnamer   ÚdescriptionÚ	messagingÚoriginÚrepo_key_filer   Úis_containerÚstatic_affordancesr   r   r   r   r*   8   s    ÿ
ÿr*   c                   @   s8   e Zd ZdZdZddgiZdZdZdZde	j
d	ffZd
S )ÚFIPSUpdatesEntitlementzfips-updateszFIPS Updatesr+   zBFIPS Updates configured and pending, please reboot to make active.ZUbuntuFIPSUpdatesz,Uncertified security updates to FIPS moduleszubuntu-fips-updates-keyring.gpgz*Cannot install FIPS Updates on a containerFN)r"   r#   r$   r,   r   r.   r/   r-   r0   r   r1   r2   r   r   r   r   r3   H   s   ÿÿýÿr3   N)Zuaclient.entitlementsr   Zuaclientr   r   r   Útypingr   r   r   r	   ÚImportErrorZRepoEntitlementr
   r*   r3   r   r   r   r   Ú<module>   s   -