HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ca_certs.cpython-311.pyc
�

܍~c$��0�UdZddlZddlmZddlmZddlmZmZddl	m
Z
ddlmZddl
mZmZdd	lmZd
ddd
dgd�Zddddddgd�iZdZgd�Zdddeeeed��gddgd�Zeed<ee��Zd�Zd �Zd!�Zd"�Zd#�Zd$ed%ed&e
d'ed(ed)dfd*�ZdS)+zCA Certs: Add ca certificates.�N)�Logger)�dedent)�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCEz/usr/share/ca-certificates/zcloud-init-ca-certs.crtz/etc/ca-certificates.confz/etc/ssl/certs/zupdate-ca-certificates)�ca_cert_path�ca_cert_filename�ca_cert_config�ca_cert_system_path�ca_cert_update_cmd�rhelz/usr/share/pki/ca-trust-source/zanchors/cloud-init-ca-certs.crtz/etc/pki/ca-trust/zupdate-ca-trustaEThis module adds CA certificates to ``/etc/ca-certificates.conf`` and updates
the ssl cert cache using ``update-ca-certificates``. The default certificates
can be removed from the system with the configuration option
``remove_defaults``.

.. note::
    certificates must be specified using valid yaml. in order to specify a
    multiline certificate, the yaml multiline list syntax must be used

.. note::
    For Alpine Linux the "remove_defaults" functionality works if the
    ca-certificates package is installed but not if the
    ca-certificates-bundle package is installed.
)�alpine�debian�ubuntur�cc_ca_certszCA CertificateszAdd ca certificatesa            ca_certs:
              remove_defaults: true
              trusted:
                - single_line_cert
                - |
                  -----BEGIN CERTIFICATE-----
                  YOUR-ORGS-TRUSTED-CA-CERT-HERE
                  -----END CERTIFICATE-----
            �ca_certs�ca-certs)�id�name�title�description�distros�	frequency�examples�activate_by_schema_keys�metac��t�|t��}tj�|d|d��|d<|S)z�Return a distro-specific ca_certs config dictionary

    @param distro_name: String providing the distro class name.
    @returns: Dict of distro configurations for ca-cert.
    rr
�ca_cert_full_path)�DISTRO_OVERRIDES�get�DEFAULT_CONFIG�os�path�join)�distro_name�cfgs  �>/usr/lib/python3/dist-packages/cloudinit/config/cc_ca_certs.py�_distro_ca_certs_configsr,NsK���
�
�{�N�
;�
;�C�!�w�|�|��N��S�!3�4� � �C����J�c�>�tj|dd���dS)z�
    Updates the CA certificate cache on the current machine.

    @param distro_cfg: A hash providing _distro_ca_certs_configs function.
    rF)�captureN)r)�
distro_cfgs r+�update_ca_certsr1[s%��	�I�j�-�.��>�>�>�>�>�>r-c��|sdSd�d�|D����}tj|d|d���t|��dS)z�
    Adds certificates to the system. To actually apply the new certificates
    you must also call L{update_ca_certs}.

    @param distro_cfg: A hash providing _distro_ca_certs_configs function.
    @param certs: A list of certificate strings.
    N�
c�,�g|]}t|����S�)�str)�.0�cs  r+�
<listcomp>z add_ca_certs.<locals>.<listcomp>os��#:�#:�#:�q�C��F�F�#:�#:�#:r-r"���mode)r(r�
write_file�update_cert_config)r0�certs�cert_file_contentss   r+�add_ca_certsrAdso���������#:�#:�E�#:�#:�#:�;�;���O��&�'�);�%������z�"�"�"�"�"r-c����d�dStj�d��jdkrd�dz}nmtj�d��}d��fd�|���D����}|����d�d�d�}tj�d|d�	��dS)
z�
    Update Certificate config file to add the file path managed cloud-init

    @param distro_cfg: A hash providing _distro_ca_certs_configs function.
    rNrz%s
r
r3c�,��g|]}|�dk�|��S)r
r5)r7�liner0s  �r+r9z&update_cert_config.<locals>.<listcomp>�s4���
�
�
���:�&8�9�9�9��9�9�9r-�wb)�omode)	r&�stat�st_sizer�	load_filer(�
splitlines�rstripr=)r0�out�orig�cr_conts`   r+r>r>vs�����"�#�+���	�w�z�*�+�,�,�4��9�9��z�"4�5�5���
�~�j�)9�:�;�;���)�)�
�
�
�
� �O�O�-�-�
�
�
�
�
��$�N�N�,�,�,�,�j�9K�.L�.L�.L�M���O�J�/�0�#�T�B�B�B�B�B�Br-c���tj|d��tj|d��tj|ddd���|dvrd}tjd	|��d
Sd
S)a
    Removes all default trusted CA certificates from the system. To actually
    apply the change you must also call L{update_ca_certs}.

    @param distro_name: String providing the distro class name.
    @param distro_cfg: A hash providing _distro_ca_certs_configs function.
    rrr�r:r;)rrz8ca-certificates ca-certificates/trust_new_crts select no)zdebconf-set-selections�-N)r�delete_dir_contentsr=r)r)r0�debconf_sels   r+�remove_default_ca_certsrT�s���	��Z��7�8�8�8���Z�(=�>�?�?�?��O�J�/�0�"�5�A�A�A�A��*�*�*�K�	�	
�	�1�;�?�?�?�?�?�	+�*r-rr*�cloud�log�args�returnc�`�d|vr|�d��nd|vr|�d|��dSd|vrd|vr|�d��|�d|�d����}t|jj��}d|vr[|�d��|�dd	��r/|�d
��t
|jj|��nE|�dd	��r/|�d
��t
|jj|��d|vrLtj|d��}|r5|�d
t|��z��t||��|�d��t|��dS)au
    Call to handle ca-cert sections in cloud-config file.

    @param name: The module name "ca-cert" from cloud.cfg
    @param cfg: A nested dict containing the entire cloud config contents.
    @param cloud: The L{CloudInit} object in use.
    @param log: Pre-initialized Python logger object to use for logging.
    @param args: Any module arguments from cloud.cfg
    rzFDEPRECATION: key 'ca-certs' is now deprecated. Use 'ca_certs' instead.rz<Skipping module named %s, no 'ca_certs' key in configurationNzMFound both ca-certs (deprecated) and ca_certs config keys. Ignoring ca-certs.zremove-defaultszfDEPRECATION: key 'ca-certs.remove-defaults' is now deprecated. Use 'ca_certs.remove_defaults' instead.FzRemoving default certificates�remove_defaults�trustedzAdding %d certificateszUpdating certificates)�warning�debugr$r,�distrorrTr�get_cfg_option_list�lenrAr1)rr*rUrVrW�ca_cert_cfgr0�
trusted_certss        r+�handlerc�s����S������
�	
�	
�	
�	
�
�3�	�	��	�	�J��	
�	
�	
�	���S���Z�3�.�.����
"�	
�	
�	
��'�'�*�c�g�g�j�&9�&9�:�:�K�)�%�,�*;�<�<�J��K�'�'����
7�	
�	
�	
��?�?�,�e�4�4�	C��I�I�5�6�6�6�#�E�L�$5�z�B�B�B��	���*�E�	2�	2�?��	�	�1�2�2�2���� 1�:�>�>�>��K����0��i�H�H�
��	4��I�I�.��]�1C�1C�C�D�D�D���]�3�3�3��I�I�%�&�&�&��J�����r-) �__doc__r&�loggingr�textwrapr�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	r
�cloudinit.settingsrr%r#�MODULE_DESCRIPTIONrr �__annotations__r,r1rAr>rTr6�listrcr5r-r+�<module>ros��
%�$�$�	�	�	�	������������� � � � � � � � �!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�+�+�+�+�+�+�2�1�1�,�3�4�����9�=��3�0�1�
�
�����1�
0�
0����
"�%�����	
�	
�	
�
�!+�J�7�+���j����0�,�t�
�
��
�
�
�?�?�?�#�#�#�$C�C�C�:@�@�@�&7 �

�7 ��7 �#(�7 �/5�7 �=A�7 �	�7 �7 �7 �7 �7 �7 r-