| Server IP : 23.254.227.96 / Your IP : 216.73.216.183 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.6/site-packages/cloudinit/config/__pycache__/ |
Upload File : |
3
��bj � @ sv d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ eZej
e�Zd
dd�Zdd d
�Zdd� ZdS )a�
Seed Random
-----------
**Summary:** provide random seed data
Since all 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. The
``file`` key specifies the path to write the data to, defaulting to
``/dev/urandom``. Data can be passed in directly with ``data``, and may
optionally be specified in encoded form, with the encoding specified in
``encoding``.
If the cloud provides its own random seed data, it will be appended to ``data``
before it is written to ``file``.
.. note::
when using a multiline value for ``data`` or specifying binary data, be
sure to follow yaml syntax and use the ``|`` and ``!binary`` yaml format
specifiers when appropriate
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.
For example, 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
**Internal name:** ``cc_seed_random``
**Module frequency:** per instance
**Supported distros:** all
**Config keys**::
random_seed:
file: <file>
data: <random string>
encoding: <raw/base64/b64/gzip/gz>
command: [<cmd name>, <arg1>, <arg2>...]
command_required: <true/false>
� N)�BytesIO)�log)�subp�util)�PER_INSTANCEc C sf | sdS | s|j � d
kr$tj| �S |j � dkr:tj| �S |j � dkrVtj| dd d�S td | ��d S )
N� �raw�base64�b64�gzip�gzF)�quiet�decodez Unknown random_seed encoding: %s)r )r r
)r r )�lowerr �encode_textr Z b64decodeZdecomp_gzip�IOError)�data�encoding� r �$/usr/lib/python3.6/cc_seed_random.py�_decodeN s
r c C sr | r|rt d��n| s&tjd� d S | d }tj|�s^|rNt dj|d���ntjd|� d S tj| |dd� d S ) Nz"no command found but required=truezno command providedr z+command '{cmd}' not found but required=true)�cmdz'command '%s' not found for seed_commandF)�envZcapture)�
ValueError�LOG�debugr Zwhich�format)�command�requiredr r r r r �handle_random_seed_command[ s
r c C s |j di �}|j dd�}|j dd�}t� }|rF|jt||j d�d�� |jj} | rnd| krn|jtj| d �� |j� }t |�r�|j
d| t |�|� tj||� |j d d �}
|j d
d�}y$tj
j� }||d<