܍~c@ PUdZddlZddlZddlmZddlmZddlmZddl m Zddl m Z m Z ddl mZdd lmZdd lmZmZdd lmZdd lmZejeZd ZdddeegeededggdZeed<eeZddZddZde dededede!ddf dZ"dS)z%Seed Random: Provide random seed dataN)BytesIO)Logger)dedent)log)subputil)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_randomz Seed 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 )idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetac4|sdS|r|dvrtj|S|dvrtj|S|dvrtj|ddSt d|z)N)raw)base64b64)gzipgzF)quietdecodez Unknown random_seed encoding: %s)lowerr encode_textr b64decode decomp_gzipIOError)dataencodings A/usr/lib/python3/dist-packages/cloudinit/config/cc_seed_random.py_decoder*Qs s Gx~~''722%%%   . . .%%%   ^ + +E$????8HEFFFrcR|s|rtd|stddS|d}tj|sB|r#td|td|dStj||ddS) Nz"no command found but required=truezno command providedrz+command '{cmd}' not found but required=true)cmdz'command '%s' not found for seed_commandF)envcapture) ValueErrorLOGdebugrwhichformat)commandrequiredr-r,s r)handle_random_seed_commandr6^s x=>>>  '((( !*C :c??  =DDDMM  II? E E E FIg3......rrcfgcloudrargsreturncj|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_seedfilez /dev/urandomr'rr()r(z0%s: adding %s bytes of random seed entropy to %sr4command_requiredFRANDOM_SEED_FILE)r4r5r-z'handling random command [%s] failed: %s)getrwriter* datasourcemetadatarr#getvaluelenr1 append_fileosenvironcopyr6r/warning)rr7r8rr9mycfg seed_path seed_dataseed_bufrCr4reqr-es r)handlerQqs GGM2 & &E &.11I &#&&IyyHKwy599Z3H3HIIIJJJ(HBMX--t'(?@@AAA!!##I 9~~/ >   NN     I...ii 4((G ))& . .Cjoo"+ "7ScJJJJJJ  =wJJJs5F F2F--F2)N)#__doc__rrGiorloggingrtextwrapr cloudinitrrrcloudinit.cloudr cloudinit.configr cloudinit.config.schemar r cloudinit.distrosr cloudinit.settingsr getLogger__name__r0MODULE_DESCRIPTIONr__annotations__r*r6strlistrQrr)rcs,++ $$$$$$ !!!!!!######<<<<<<<<))))))++++++g!!&   '%}     . "=jB ,t   G G G G////&# ###(#/5#=A# ######r