HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_seed_random.cpython-36.pyc
3

\�me��	@s�UdZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZmZdd	lmZdd
lmZeje�ZdZdd
deegeed�ed�ggd�Zeee�Zddd�Zddd�Zeeeedd�dd�ZdS)z%Seed Random: Provide random seed data�N)�BytesIO)�dedent)�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.
Zcc_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�descriptionZdistrosZ	frequencyZexamplesZactivate_by_schema_keyscCsf|sdS|s|j�d
kr$tj|�S|j�dkr:tj|�S|j�dkrVtj|ddd�Std	|��dS)
N��raw�base64�b64�gzip�gzF)�quiet�decodez Unknown random_seed encoding: %s)r)rr)rr)�lowerr�encode_textrZ	b64decodeZdecomp_gzip�IOError)�data�encoding�r�$/usr/lib/python3.6/cc_seed_random.py�_decodePs

rcCsr|r|rtd��n|s&tjd�dS|d}tj|�s^|rNtdj|d���ntjd|�dStj||dd�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)�envZcapture)�
ValueError�LOG�debugrZwhich�format)�command�requiredr!r rrr�handle_random_seed_command]s



r()r
�cfg�cloud�args�returnc
Cs|jdi�}|jdd�}|jdd�}t�}|rF|jt||jd�d��|jj}|rnd|krn|jtj|d��|j�}t	|�r�t
jd|t	|�|�tj||�|jd	d�}	|jd
d�}
y$t
jj�}||d<t|	|
|d
�Wn6tk
�r}zt
jd|	|�|�WYdd}~XnXdS)NZrandom_seed�filez/dev/urandomrrr)rz0%s: adding %s bytes of random seed entropy to %sr&Zcommand_requiredFZRANDOM_SEED_FILE)r&r'r!z'handling random command [%s] failed: %s)�getr�writerZ
datasource�metadatarr�getvalue�lenr#r$Zappend_file�os�environ�copyr(r"Zwarning)
r
r)r*r+ZmycfgZ	seed_pathZ	seed_dataZseed_bufr0r&Zreqr!�errr�handleps4
r7)N)N) �__doc__rZloggingr3�ior�textwraprZ	cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarr	Zcloudinit.distrosr
Zcloudinit.settingsrZ	getLogger�__name__r#ZMODULE_DESCRIPTION�metarr(�str�listr7rrrr�<module>	s8