+
    i9                     J   ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHtHt ] P"                  ! ]4      t]P(                  t]P*                  t]P,                  tRtR	R
.tRR.tR.tR	tRtRt. ROtRtR.t R t!R t"RR lt# ! R R4      t$R t%]3R lt&R# )    N)MIMEBase)MIMEMultipart)MIMENonMultipart)MIMEText)featureshandlersutil)UrlErrorread_file_or_urlzContent-Typez
text/plainztext/x-not-multipartztext/x-include-urlztext/x-include-once-urlztext/cloud-config-archiveztext/cloud-configzapplication/octet-streamzNumber-Attachmentsc                     W W V&   R # N )msgkeyvalues   &&&5/usr/lib/python3/dist-packages/cloudinit/user_data.py_replace_headerr   ;   s    H    c                 F    V R  V P                  R R\        V4      R7       R# )zContent-Disposition
attachment)filenameN)
add_headerstr)r   r   s   &&r   _set_filenamer   @   s"    !"NN(,XNOr   c                 t    \         P                  '       d   \        V 4      Vh\        P	                  V 4       R # r   )r   ERROR_ON_USER_DATA_FAILURERuntimeErrorLOGwarning)error_messagesource_exceptions   &&r   _handle_errorr"   E   s(    ***=)/??M"r   c                   `   a  ] tR t^Lt o R tR tR tR tR tR t	R t
R tRR
 ltR tRtV tR	# )UserDataProcessorc                H    Wn         \        P                  ! V4      V n        R # r   )pathsr	   fetch_ssl_detailsssl_details)selfr&   s   &&r   __init__UserDataProcessor.__init__M   s    
11%8r   c                    \        4       p\        V\        4      '       d'   V F  pV P                  \	        V4      V4       K   	  V# V P                  \	        V4      V4       V# r   )r   
isinstancelist_process_msgconvert_string)r)   blobaccumulating_msgbs   &&  r   processUserDataProcessor.processQ   s]    (?dD!!!!."35EF    nT24DEr   c           
        R  pVP                  4        EF  p\        V4      '       d   K  RpVP                  4       p\        P                  ! V4      pRpV\
        9   d    \        P                  ! VRR7      pRpRpV'       g   \        pV\        R.,           9   d	   V! V4      pVf   TpV'       d   VP                  R^4      w  r\        W4      pVP                  V4       VP!                  4       '       d   \#        WP!                  4       4       R F&  pW9   g   K  \%        W\'        WN,          4      4       K(  	  TpWV8w  d   \%        V\(        V4       V\*        9   d   V P-                  Wr4       EKc  V\.        9   d   V P1                  Wr4       EK  \%        V\(        V4       V P3                  W$4       EK  	  R#   \        P                   d4   p	RP                  T\        T4      T	4      p
\        Y4        Rp	?	EK  Rp	?	ii ; i)	c                 .    \         P                  ! V 4      # r   )r   type_from_starts_with)payloads   &r   
find_ctype2UserDataProcessor._process_msg.<locals>.find_ctype[   s    11'::r   NF)quietTz<Failed decompressing payload from {} of length {} due to: {}ztext/x-shellscript/)Launch-Index)walkis_skippableget_content_typer	   fully_decoded_payloadDECOMP_TYPESdecomp_gzipDecompressionErrorformatlenr"   
UNDEF_TYPETYPE_NEEDEDsplitr   set_payloadget_filenamer   r   r   CONTENT_TYPEINCLUDE_TYPES_do_includeARCHIVE_TYPES_explode_archive_attach_part)r)   base_msg
append_msgr:   partctype
ctype_origr9   was_compresseder    maintypesubtypen_parths   &&&            r   r/   UserDataProcessor._process_msgZ   s   	; MMODD!!E..0J006G"N
 \)"..weDG "&J%)N '
 [,@+AAA"7+}" $)KKQ$7!)(<""7+ $$&&!&*;*;*=>*Ay'3tw<@ + "lE:%  5%%%g: HlE:j/U $& .. 006&Ga1 " "-3s   !F??H'HHc                   VP                  R R4      pRpVP                  4       \        9   dA    \        P                  ! VP                  RR7      4      pV'       d   VP                  R4      pVe   TpVf   TpVe(    VP                  R \        \        V4      4      4       R# R#   \         d     LFi ; i  \        \        3 d     R# i ; i)r>   NTdecodelaunch-index)getrA   EXAMINE_FOR_LAUNCH_INDEXr	   	load_yamlget_payload	Exceptionr   r   int
ValueError	TypeError)r)   r   
header_idxpayload_idxr9   s   &&   r   _attach_launch_index&UserDataProcessor._attach_launch_index   s    WW^T2
!%== ..)EF")++n"=K !$K$K"~s3{3C/DE #   	* s)   -B' B' ?$B8 'B54B58CCc                    \         P                  ! VR ^@4      p\        P                  P	                  V P
                  P                  R4      RV4      # )md5dataurlcache)r	   	hash_blobospathjoinr&   get_ipath_cur)r)   entryentry_fns   && r   _get_include_once_filename,UserDataProcessor._get_include_once_filename   s?    >>%3ww||JJ$$V,j(
 	
r   c                    VP                  4       '       g   \        V\        V,          4       V P                  V4       R # r   )rL   r   PART_FN_TPLrm   )r)   r   attached_ids   &&&r   _process_before_attach(UserDataProcessor._process_before_attach   s.    !!#{k:;!!#&r   c                   R pVP                  4        EF  pVP                  4       pVP                  R4      '       d    V\        R4      R P	                  4       pRpM5VP                  R4      '       d   V\        R4      R P	                  4       pR pVP                  R4      '       d   K  VP                  4       pV'       g   K  RpRpV'       d   V P                  V4      pV'       d=   \        P                  P                  V4      '       d   \        P                  ! V4      pM \        V^^
V P                  R7      pV'       d9   VP                  4       '       d#   \        P                  ! WxP                   RR7       VP                  4       '       d   VP                   pM'R	P#                  WhP$                  4      p	\'        V	4        Vf   EK  \/        V4      pV P1                  W4       EK  	  R#   \(         d?   p
\+        T
4      pYk9  d   TR
P#                  T4      ,          p\'        Y4        Rp
?
LnRp
?
i\,         d'   pRP#                  Yl4      p	\'        Y4        Rp?LRp?ii ; i)Fz#include-onceNTz#include#)timeoutretriesr(   i  )modez6Fetching from {} resulted in a invalid http code of {}z for url: {0}zFetching from {} resulted in {})
splitlineslower
startswithrG   lstripstriprz   rt   ru   isfiler	   load_text_filer   r(   ok
write_filecontentsrF   coder"   r
   r   IOErrorr0   r/   )r)   contentrT   include_once_onlinelc_lineinclude_urlinclude_once_fnrespr    urlemessageioenew_msgs   &&&           r   rO   UserDataProcessor._do_include   s     &&(DjjlG!!/22C023::< #'##J//C
O-.557 #(s##**,K"OG"&"A"A+"N277>>/#B#B--o> 6+# ! "$($4$4	D '47799+]] wwyy"&--99? +YY: & &m4 "(1!!'6} )^   1!$iG #1?#9#9+#FF!'00 6$E$L$L#%M "-55	6s<   '6G47G4G4#&G44I,?4H88I,I,I''I,c                   \         P                  ! V. \        \        3R 7      pV EF  p\	        V\
        4      '       d   RV/p\	        V\        4      '       g   K6  VP                  RR4      pVP                  R4      pV'       g9   \        p\	        V\        4      '       d   \        p\        P                  ! WW4      pVP                  R^4      w  rVR8X  d4   \	        V\        4      '       d   VP                  4       p\        WYR7      p
M\!        W4      p
V
P#                  V4       RV9   d   \%        WR,          4       RV9   d#   V
P'                  R	\        VR,          4      4       \        VP)                  4       4       F]  pVP+                  4       RRRRR
\,        P+                  4       \.        P+                  4       39   d   KE  V
P'                  WV,          4       K_  	  V P1                  W*4       EK  	  R# ))defaultallowedr    typer=   text)_subtyper   rb   r>   zcontent-dispositionN)r	   re   r.   setr-   r   dictrc   ARCHIVE_UNDEF_TYPEbytesARCHIVE_UNDEF_BINARY_TYPEr   r8   rJ   ra   r   r   rK   r   r   keysr   ATTACHMENT_FIELDrM   rR   )r)   archiverT   entriesentr   mtyper   rZ   r[   r   headers   &&&         r   rQ   "UserDataProcessor._explode_archive  s   .."tSkJC #s## #&cD**ggi,GGGFOE,gu--7G 66wH %C 3H6!gu--%nn.Gw9x1(S cz?3$~s3~3F/GHsxxz*<<>")$**, &&(&  v6{3 + j.a r   Nc                   \         V9  d
   RV\         &   Ve   \        V\         \        V4      4       ^ p \        VP	                  \         4      4      pV#   \
        \        3 d    \        T\         \        T4      4        T# i ; i)zg
Return the number of attachments to this MIMEMultipart by looking
at its 'Number-Attachments' header.
0)r   r   r   rh   rc   ri   rj   )r)   	outer_msg	new_countfetched_counts   &&& r   _multi_part_count#UserDataProcessor._multi_part_countF  s    
 9,*-I&' I'7YH	M	.> ?@M  I& 	MI'7]9KL	Ms   A +BBc                    V P                  V4      pV P                  W#^,           4       VP                  V4       V P                  W^,           4       R# )z
Attach a message to an outer message. outermsg must be a MIMEMultipart.
Modifies a header in the outer message to keep track of number of
attachments.
N)r   r   attach)r)   r   rU   
part_counts   &&& r   rR   UserDataProcessor._attach_partX  sF     ++I6
##Dq.9yq.9r   )r&   r(   r   )__name__
__module____qualname____firstlineno__r*   r4   r/   rm   rz   r   rO   rQ   r   rR   __static_attributes____classdictcell__)__classdict__s   @r   r$   r$   L   sA     9 N0`0
'
C7J2/h$	: 	:r   r$   c                 h    V P                  4       ;'       g    R pVP                  4       R8X  d   R# R# )r   	multipartTF)get_content_maintyper   )rU   part_maintypes   & r   r@   r@   d  s/    --/552M+r   c                :   V '       g   Rp R p\        V \        4      '       d   V P                  R4      pMT p\        P                  ! VRR7      pRVR,          P                  4       9   d(   \        P                  ! VP                  R4      4      pV# V! W14      pV# )zFconvert a string (more likely bytes) or a message into
a mime message.r   c                 f    VP                  R ^4      w  r#\        W#4      pVP                  V 4       V# )r=   )rJ   r   rK   )rq   content_typerZ   r[   r   s   &&   r   create_binmsg%convert_string.<locals>.create_binmsgs  s2    (..sA6x)
r   zutf-8Fr`   s   mime-version::r   i   N)r-   r   encoder	   rD   r   message_from_stringra   )raw_datar   r   bdatar   s   &&   r   r0   r0   m  s      (C  (U51E5=..00&&u||G'<= J E0Jr   )zapplication/gzipzapplication/gzip-compressedzapplication/gzippedzapplication/x-compresszapplication/x-compressedzapplication/x-gunzipzapplication/x-gzipzapplication/x-gzip-compressedr   )'loggingrt   email.mime.baser   email.mime.multipartr   email.mime.nonmultipartr   email.mime.textr   	cloudinitr   r   r	   cloudinit.url_helperr
   r   	getLoggerr   r   NOT_MULTIPART_TYPEr}   
OCTET_TYPErM   rI   rN   rP   rH   r   r   rC   r   rd   r   r   r"   r$   r@   r0   r   r   r   <module>r      s     	 $ . 4 $ . . ;! 00 ""  
  34%'@A,-
( 6 	 (  00 
P
#U: U:p += r   