+
    ˜qgjú  ã                   ó–   € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
 ^ RIHt ]P                  ! ]4      tRt ! R R4      tR# )z0gpg.py - Collection of gpg key related functionsN)ÚTemporaryDirectory)ÚDictÚOptional)ÚsubpÚ	GNUPGHOMEc                   óê   a € ] tR t^t o R tR t]V 3R lR l4       tR tV 3R lR lt	V 3R lR	 lt
V 3R
 lR ltRV 3R lR lltRV 3R lR lltV 3R lR ltRV 3R lR lltV 3R lR ltRtV tR# )ÚGPGc                ó@   € R V n         / V n        \        4       V n        R# )FN)Úgpg_startedÚ_envr   Útemp_dir©Úselfs   &Ú//usr/lib/python3/dist-packages/cloudinit/gpg.pyÚ__init__ÚGPG.__init__   s   € Ø ˆÔØˆŒ	Ü*Ó,ˆŽó    c                ó   € V # ©N© r   s   &r   Ú	__enter__ÚGPG.__enter__   s   € Øˆr   c                ó6   <€ V ^8„  d   QhRS[ S[S[3,          /# )é   Úreturn)r   Ústr)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚGPG.__annotate__#   s   ø€ ÷ ñ ‘T™#™s˜(•^ñ r   c                ó¦   € V P                   '       d   V P                   # RV n        \        V P                  P                  /V n         V P                   # )zò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   ÚenvÚGPG.env"   s?   € ð �9�9ˆ9Ø—9‘9ÐØˆÔÜ˜4Ÿ=™=×-Ñ-Ð.ˆŒ	Ø�y‰yÐr   c                ó&   € V P                  4        R # r   )Úcleanup)r   Úexc_typÚ	exc_valueÚ	tracebacks   &&&&r   Ú__exit__ÚGPG.__exit__1   s   € Ø�‰Žr   c                ó   <€ V ^8„  d   QhRR/# ©r   r   Nr   )r   r   s   "€r   r   r   4   s   ø€ ÷ $ñ $˜ñ $r   c                óø   € V P                  4        V P                  '       dX   \        P                  P	                  V P                  P
                  4      '       d   V P                  P                  4        R# R# R# )z0cleanup the gpg temporary directory and kill gpgN)Úkill_gpgr   ÚosÚpathÚisdirr"   r&   r   s   &r   r&   ÚGPG.cleanup4   sG   € à�‰ŒØ�=�=ˆ=œRŸW™WŸ]™]¨4¯=©=×+=Ñ+=×>Ò>Ø�M‰M×!Ñ!Ö#ñ ?‰=r   c                ó6   <€ V ^8„  d   QhRS[ RS[S[ ,          /# ©r   Úkeyr   ©r   r   )r   r   s   "€r   r   r   :   s   ø€ ÷ ñ ¡ð ©±#­ñ r   c                óØ   €  \         P                   ! RRRV.RV P                  R7      P                  #   \         P                   d"   p\        P                  RY4        Rp?R# Rp?ii ; i)z*Export gpg key, armoured key gets returnedÚgpgz--exportz--armourT©ÚcaptureÚ
update_envú&Failed to export armoured key "%s": %sN)r   r#   ÚstdoutÚProcessExecutionErrorÚLOGÚdebug©r   r6   Úerrors   && r   Úexport_armourÚGPG.export_armour:   se   € ð	LÜ—9’9Ø˜
 J°Ð4ØØŸ8™8ô÷ ‰fð	øô
 ×)Ñ)ô 	Lä�I‰IÐ>À×KÐKÙûð	Lús   ‚03 ³A)ÁA$Á$A)c                ó&   <€ V ^8„  d   QhRS[ RS[ /# r5   ©r   )r   r   s   "€r   r   r   G   s   ø€ ÷ ñ ™3ð ¡3ñ r   c                ób   € \         P                   ! RR.VRV P                  R7      P                  # )zvDearmor gpg key, dearmored key gets returned

note: man gpg(1) makes no mention of an --armour spelling, only --armor
r9   z	--dearmorF)ÚdataÚdecoder<   )r   r#   r>   )r   r6   s   &&r   ÚdearmorÚGPG.dearmorG   s,   € ô
 �yŠyØ�KÐ  s°5ÀTÇXÁXô
ç
‰&ð	r   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r   Úkey_filer   rG   )r   r   s   "€r   r   r   P   s   ø€ ÷ ñ ¡#ð ¹cñ r   c                óæ   € . ROpV'       g   VP                  R4       VP                  V4       \        P                  ! W0P                  RR7      w  rEV'       d   \        P	                  RW4       V# )zÒList 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
z--with-colonsT)r<   r;   r=   )r9   z--no-optionsz--with-fingerprintz--no-default-keyringz--list-keysz	--keyring)Úappendr   r#   r@   Úwarning)r   rN   Úhuman_outputÚcmdr>   Ústderrs   &&&   r   Ú	list_keysÚGPG.list_keysP   sW   € ò
ˆ÷ Ø�J‰J�Ô'à�
‰
�8ÔÜŸš 3·8±8ÀTÔJ‰ˆßÜ�K‰KØ8¸(ôð ˆr   c                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r   r6   Ú	keyserverr   NrG   )r   r   s   "€r   r   r   j   s"   ø€ ÷ 5ñ 5™Cð 5©Cð 5ÀDñ 5r   c                ó*  € \         P                  RW4       ^ pRp\        T;'       g    . 4      p V^,          p \        P                  ! RRRV,          RV.RV P                  R7       \         P                  R	VVV4       R#   \        P
                   d   pTp Rp?MRp?ii ; i \        T4      p\         P                  R
TP                  T4       \        P                  ! T4       K½    \         d   p\        RYYE3,          4      ThRp?ii ; i)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'NTr9   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)r@   rA   Úiterr   r#   r?   ÚnextÚ	exit_codeÚtimeÚsleepÚStopIterationÚ
ValueError)	r   r6   rX   ÚretriesÚtrynumrC   ÚsleepsÚeÚnaplens	   &&&&     r   Úrecv_keyÚGPG.recv_keyj   s  € ô 	�	‰	Ð:¸CÔKØˆØˆÜ�g—m�m Ó$ˆØØ�a�KˆFðÜ—	’	àØ"Ø(¨9Õ4Ø%Øðð !Ø#Ÿx™xõ
ô —	‘	ØEØØØô	ñ øÜ×-Ñ-ô Ø•ûðúðÜ˜f›�Ü—	‘	ØLØ—O‘OØôô
 —
’
˜6Ö"øÜ ô Ü ð)Ø,/¸FÐ+JõKóð ðûðús1   »AB ÂB%ÂB Â B%Â)AC- Ã-DÃ8DÄDc                ó$   <€ V ^8„  d   QhRS[ RR/# )r   r6   r   NrG   )r   r   s   "€r   r   r   ¡   s   ø€ ÷ 	Bñ 	B™cð 	B dñ 	Br   c                óÊ   €  \         P                   ! RRRRV.RV P                  R7       R#   \         P                   d"   p\        P	                  RY4        Rp?R# Rp?ii ; i)	z0Delete the specified key from the local gpg ringr9   z--batchz--yesz--delete-keysTr:   zFailed delete key "%s": %sN)r   r#   r?   r@   rQ   rB   s   && r   Ú
delete_keyÚGPG.delete_key¡   sX   € ð	BÜ�IŠIØ˜	 7¨O¸SÐAØØŸ8™8÷øô
 ×)Ñ)ô 	BÜ�K‰KÐ4°c×AÒAûð	Bús   ‚(, ¬A"ÁAÁA"c                ó<   <€ V ^8„  d   QhRS[ RS[ RS[S[ ,          /# )r   ÚkeyidrX   r   r7   )r   r   s   "€r   r   r   ¬   s)   ø€ ÷ ñ ÙðÙ%(ðá	‘#�ñr   c                ó   € V P                  V4      pV'       g9    V P                  WR7       V P                  V4      p T P                  T4       T# V#   \         d    \        P	                  RT4       h i ; i  T P                  T4       i ; i)zget gpg keyid from keyserver)rX   zFailed to obtain gpg key %s)rD   rf   r`   r@   Ú	exceptionrj   )r   rm   rX   Úarmours   &&& r   Ú
getkeybyidÚGPG.getkeybyid¬   sƒ   € ð ×#Ñ# EÓ*ˆßð	'Ø—‘˜e�Ô9Ø×+Ñ+¨EÓ2‘ð —‘ Ô&Øˆˆvˆøô ô Ü—‘Ð;¸UÔCØðûð —‘ Õ&ús   ›#A Á#A7Á7A: Á:Bc                ó   <€ V ^8„  d   QhRR/# r-   r   )r   r   s   "€r   r   r   ¾   s   ø€ ÷ .Añ .A˜$ñ .Ar   c                óº  €  V P                   '       g   R# \        P                  ! R4      '       d2   \        P                  ! . R
ORV P                  R7      P                  pR# \        P                  ! . ROR^ ^.R7      P                  p\
        P                  ! RV4      pV Uu. uF$  q3^ ,          R8X  g   K  \        V^,          4      NK&  	  ppV'       d   \        P                  RV4       V F(  p\        P                  ! V\        P                  4       K*  	  R# u upi   \        P                   d"   p\        P                  R	T4        Rp?R# Rp?ii ; i)zçkilling with gpgconf is best practice, but when it isn't available
failover is possible

GH: 4344 - stop gpg-agent/dirmgr daemons spawned by gpg
key imports. Daemons spawned by cloud-config.service on systemd
v253 report (running)
NÚgpgconfTr:   )r;   Úrcsz(?P<ppid>\d+)\s+(?P<pid>\d+)Ú1z&Killing gpg-agent and dirmngr pids: %sz"Failed to clean up gpg process: %s)ru   z--killÚall)	Úpsz-ozppid,pidú-CÚkeyboxdrz   Údirmngrrz   z	gpg-agent)r
   r   Úwhichr#   r>   ÚreÚfindallÚintr@   rA   r0   ÚkillÚsignalÚSIGKILLr?   rQ   )r   Úgpg_process_outÚgpg_pidsÚpidÚroot_gpg_pidsÚgpg_pidrd   s   &      r   r/   ÚGPG.kill_gpg¾   s   € ð&	AØ×#×#Ð#ÙÜ�zŠz˜)×$Ò$Ü"&§)¢)Ú0Ø Ø#Ÿx™xô#÷ ‘&ò	  ô #'§)¢)ò
ð !Ø˜A˜ô#÷ ‘&ð  ô Ÿ:š:Ø3°_ó�ñ ,4ó!Ù+3 C¸1µvÀ±}”K”C˜˜A�–K©8ð ð !÷ !Ü—I‘IØ@À-ôó  -�GÜ—G’G˜G¤V§^¡^Ö4ó  -ùò!øô ×)Ñ)ô 	AÜ�K‰KÐ<¸a×@Ò@ûð	AúsA   ‚D$ –D$ ²/D$ Á#AD$ Â%DÂ9DÃAD$ ÄD$ Ä$EÄ9EÅE)r   r
   r   N)F))é   rŠ   )zkeyserver.ubuntu.com)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r   Úpropertyr#   r*   r&   rD   rK   rU   rf   rj   rq   r/   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s}   ø‡ € ò-ò
ð ÷ó ðò÷$ð $÷ð ÷ð ÷ò ÷45ò 5÷n	Bð 	B÷ò ÷$.Aö .Ar   r   )Ú__doc__Úloggingr0   r~   r‚   r]   Útempfiler   Útypingr   r   Ú	cloudinitr   Ú	getLoggerr‹   r@   r!   r   r   r   r   Ú<module>r˜      sE   ðñ 7ã Û 	Û 	Û Û Ý 'ß !å à×Ò˜Ó!€à€÷SAó SAr   