⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.144
Server IP:
157.245.143.252
Server:
Linux www 6.11.0-9-generic #9-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 14 13:19:59 UTC 2024 x86_64
Server Software:
nginx/1.26.0
PHP Version:
8.3.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
cloudinit
/
__pycache__
/
View File Name :
gpg.cpython-312.pyc
f d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z m Z ddlmZ ej e ZdZ G d d Zy) z0gpg.py - Collection of gpg key related functions N)TemporaryDirectory)DictOptional)subp GNUPGHOMEc e Zd Zd Zd Zedeeef fd Zd Z ddZ dedee fd Zdedefd Z ddedefdZdded eddfdZdeddfdZ dded edee fdZddZy)GPGc > d| _ i | _ t | _ y )NF)gpg_started_envr temp_dirselfs //usr/lib/python3/dist-packages/cloudinit/gpg.py__init__zGPG.__init__ s *, c | S N r s r __enter__z GPG.__enter__ s r returnc | j r| j S d| _ t | j j i| _ | j S )a when this env property gets invoked, set up our temporary directory, and also set gpg_started to tell the cleanup() method whether or not why put this here and not in __init__? pytest seems unhappy and it's not obvious how to work around it T)r r HOMEr namer s r envzGPG.env" s= 99994==--. yyr c $ | j y r )cleanup)r exc_typ exc_value tracebacks r __exit__zGPG.__exit__1 s r Nc | j | j rOt j j | j j r| j j yyy)z0cleanup the gpg temporary directory and kill gpgN)kill_gpgr ospathisdirr r r s r r zGPG.cleanup4 sB ==RWW]]4==+=+=>MM!!# ?=r keyc t j ddd|gd| j j S # t j $ r!}t j d|| Y d}~yd}~ww xY w)z*Export gpg key, armoured key gets returnedgpgz--exportz--armourTcapture update_env&Failed to export armoured key "%s": %sN)r r stdoutProcessExecutionErrorLOGdebugr r' errors r export_armourzGPG.export_armour: sg L99 J488 f )) LII>UKK Ls /2 A&A!!A&c ` t j ddg|d| j j S )zDearmor gpg key, dearmored key gets returned note: man gpg(1) makes no mention of an --armour spelling, only --armor r) z --dearmorF)datadecoder, )r r r. )r r' s r dearmorzGPG.dearmorG s, yy K s5TXX & r key_filec g d}|s|j d |j | t j || j d \ }}|rt j d|| |S )zList keys from a keyring with fingerprints. Default to a stable machine parseable format. @param key_file: a string containing a filepath to a key @param human_output: return output intended for human parsing )r) z--no-optionsz--with-fingerprintz--no-default-keyringz--list-keysz --keyringz --with-colonsT)r, r+ r- )appendr r r0 warning)r r9 human_outputcmdr. stderrs r list_keysz GPG.list_keysP s] JJ' 83488TJKK8(F r keyserverc t j d|| d}d}t |xs g } |dz } t j ddd|z d |gd| j t j d||| y# t j $ r}|}Y d}~nd}~ww xY w t | }t j d|j | t j | n$# t $ r}t d ||||fz |d}~ww xY w)a Receive gpg key from the specified keyserver. Retries are done by default because keyservers can be unreliable. Additionally, there is no way to determine the difference between a non-existent key and a failure. In both cases gpg (at least 2.2.4) exits with status 2 and stderr: "keyserver receive failed: No data" It is assumed that a key provided to cloud-init exists on the keyserver so re-trying makes better sense than failing. @param key: a string key fingerprint (as passed to gpg --recv-keys). @param keyserver: the keyserver to request keys from. @param retries: an iterable of sleep lengths for retries. Use None to indicate no retries.z&Importing key '%s' from keyserver '%s'r NT r) z--no-ttyz--keyserver=%sz--recv-keysr* z/Imported key '%s' from keyserver '%s' on try %dz6Import failed with exit code %d, will try again in %ssz@Failed to import key '%s' from keyserver '%s' after %d tries: %s)r0 r1 iterr r r/ next exit_codetimesleep StopIteration ValueError) r r' rA retriestrynumr3 sleepsenaplens r recv_keyzGPG.recv_keyj s :CKgm$aKF "(94% !#xx E -- f LOO 6" ),/FE+JK ? s1 AA5 5BBBAC C;#C66C;c t j dddd|gd| j y# t j $ r!}t j d|| Y d}~yd}~ww xY w) z0Delete the specified key from the local gpg ringr) z--batchz--yesz --delete-keysTr* zFailed delete key "%s": %sN)r r r/ r0 r<