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_seed_random.cpython-311.pyc
�

܍~c@��P�UdZddlZddlZddlmZddlmZddlmZddl	m
Zddl	mZmZddl
mZdd	lmZdd
lmZmZddlmZddlmZeje��Zd
Zdddeegeed��ed��ggd�Zeed<ee��Zdd�Zdd�Zde dededede!ddfd�Z"dS)z%Seed Random: Provide random seed data�N)�BytesIO)�Logger)�dedent)�log)�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS)�PER_INSTANCEaPAll cloud instances started from the same image will produce very similar
data when they are first booted as they are all starting with the same seed
for the kernel's entropy keyring. To avoid this, random seed data can be
provided to the instance either as a string or by specifying a command to run
to generate the data.

Configuration for this module is under the ``random_seed`` config key. If
the cloud provides its own random seed data, it will be appended to ``data``
before it is written to ``file``.

If the ``command`` key is specified, the given command will be executed.  This
will happen after ``file`` has been populated.  That command's environment will
contain the value of the ``file`` key as ``RANDOM_SEED_FILE``. If a command is
specified that cannot be run, no error will be reported unless
``command_required`` is set to true.
�cc_seed_randomzSeed RandomzProvide random seed dataz�            random_seed:
              file: /dev/urandom
              data: my random string
              encoding: raw
              command: ['sh', '-c', 'dd if=/dev/urandom of=$RANDOM_SEED_FILE']
              command_required: true
            a_            # To use 'pollinate' to gather data from a remote entropy
            # server and write it to '/dev/urandom', the following
            # could be used:
            random_seed:
              file: /dev/urandom
              command: ["pollinate", "--server=http://local.polinate.server"]
              command_required: true
            )�id�name�title�description�distros�	frequency�examples�activate_by_schema_keys�metac�4�|sdS|r|���dvrtj|��S|���dvrtj|��S|���dvrtj|dd���St
d|z���)N�)�raw)�base64�b64)�gzip�gzF)�quiet�decodez Unknown random_seed encoding: %s)�lowerr�encode_textr�	b64decode�decomp_gzip�IOError)�data�encodings  �A/usr/lib/python3/dist-packages/cloudinit/config/cc_seed_random.py�_decoder*Qs������s��G�x�~�~�'�'�7�2�2����%�%�%�	���	�	�.�	.�	.����%�%�%�	���	�	�^�	+�	+����E�$�?�?�?�?��8�H�E�F�F�Frc�R�|s|rtd���|st�d��dS|d}tj|��sB|r#td�|������t�d|��dStj||d���dS)	Nz"no command found but required=truezno command providedrz+command '{cmd}' not found but required=true)�cmdz'command '%s' not found for seed_commandF)�env�capture)�
ValueError�LOG�debugr�which�format)�command�requiredr-r,s    r)�handle_random_seed_commandr6^s�����x���=�>�>�>�
���	�	�'�(�(�(���
�!�*�C��:�c�?�?���	��=�D�D��D�M�M���
�
�I�I�?��E�E�E��F��I�g�3��.�.�.�.�.�.rr�cfg�cloudr�args�returnc�j�|�di��}|�dd��}|�dd��}t��}|r7|�t||�d�������|jj}	|	r1d|	vr-|�t
j|	d����|���}t|��r:|�
d|t|��|��t
j||��|�d	d��}
|�d
d��}	tj
���}||d<t|
||�
��dS#t $r}
|�d|
|
��|
�d}
~
wwxYw)N�random_seed�filez/dev/urandomr'rr()r(z0%s: adding %s bytes of random seed entropy to %sr4�command_requiredF�RANDOM_SEED_FILE)r4r5r-z'handling random command [%s] failed: %s)�getr�writer*�
datasource�metadatarr#�getvalue�lenr1�append_file�os�environ�copyr6r/�warning)rr7r8rr9�mycfg�	seed_path�	seed_data�seed_bufrCr4�reqr-�es              r)�handlerQqs���
�G�G�M�2�&�&�E��	�	�&�.�1�1�I��	�	�&�#�&�&�I��y�y�H��K����w�y�5�9�9�Z�3H�3H�I�I�I�J�J�J���(�H��B�M�X�-�-����t�'���(?�@�@�A�A�A��!�!�#�#�I�
�9�~�~�/��	�	�>���	�N�N��		
�	
�	
�	
���I�.�.�.��i�i�	�4�(�(�G�
�)�)�&��
.�
.�C���j�o�o����"+����"�7�S�c�J�J�J�J�J�J���������=�w��J�J�J����������s�5F
�

F2�F-�-F2)N)#�__doc__rrG�ior�loggingr�textwrapr�	cloudinitrrr�cloudinit.cloudr	�cloudinit.configr
�cloudinit.config.schemarr�cloudinit.distrosr
�cloudinit.settingsr�	getLogger�__name__r0�MODULE_DESCRIPTIONr�__annotations__r*r6�str�listrQ�rr)�<module>rcs���,�+�+�
�
�
�
�	�	�	�	�������������������$�$�$�$�$�$� � � � � � � � �!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�)�)�)�)�)�)�+�+�+�+�+�+��g���!�!����&��
'�%��}����
�		
�		
�	��
�
	
�
	
��. "�=���j����B�,�t�
�
��
G�
G�
G�
G�/�/�/�/�&#�

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