ó
    x[ht9  ã                   óî  • S r SSKrSSKrSSKrSSKJr  SSKJrJrJr  SSK	r	SSK
JrJrJr  SSKJr  SSKJr  SSKJr  \R(                  " \5      rS	rS
rSrSrS\4S jrS\\   4S jrS\4S jrS\4S jrS\S\\   4S jr S\\   4S jr! " S S5      r"S\\   S\S\#4S jr$S\S\\\"   \\"   4   4S jr%S\\"   S\\"   S\\   4S jr& " S S\RN                  5      r(\(\RR                  44/r*S  r+g)!z?Datasource to support the Windows Subsystem for Linux platform.é    N)ÚPurePath)ÚListÚOptionalÚTuple)ÚsourcesÚsubpÚutil)ÚDistro)Útype_from_starts_with)ÚPathsz/usr/bin/wslpathziid-datasource-wslú%s.user-dataz
agent.yamlÚreturnc                  ó†   • [         R                   " [        SS/5      u  p[        U R                  5       5      R                  $ )zD
Returns the name of the current WSL instance as seen from outside.
z-amÚ/)r   ÚWSLPATH_CMDr   ÚrstripÚname)Úroot_net_pathÚ_s     ÚA/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceWSL.pyÚinstance_namer      s6   € ô —y’y¤+¨u°cÐ!:Ó;Ñ€MÜ�M×(Ñ(Ó*Ó+×0Ñ0Ð0ó    c                  ó¸   • Sn Sn/ n[         R                  " 5       R                  5        H,  nUS   U :X  d  M  XS   ;   d  M  UR                  US   5        M.     U$ )zˆ
Return a list of mount points of the Windows drives inside the current
WSL instance, if drives are mounted, or an empty list otherwise
Ú9pzaname=drvfsÚfstypeÚoptsÚ
mountpoint)r	   ÚmountsÚvaluesÚappend)ÚFS_TYPEÚOPTIONS_CONTAINÚmountedÚmnts       r   Úmounted_win_drivesr%   +   sY   € ð
 €GØ#€Oà€GÜ�{Š{‹}×#Ñ#Ö%ˆØˆx‰=˜GÕ#¨¸v¹;Õ(FØ�N‰N˜3˜|Ñ,Ö-ñ &ð €Nr   c                  ó,  • [        5       n U (       d  [        S5      eSnU  HT  nX-  n[        R                  " U[        R                  5      (       d  M3  [
        R                  SU5        [        U5      s  $    [        SSR                  U 5      -  5      e)z7
Returns the Linux path to the Windows host's cmd.exe.
zWindows drives are not mounted.z%s/Windows/System32/cmd.exezFound cmd.exe at <%s>z,Couldn't find cmd.exe in any mount point: %sz, )	r%   ÚIOErrorÚosÚaccessÚX_OKÚLOGÚdebugr   Újoin)r   Ú	candidater$   Úcmds       r   Úcmd_executabler0   ;   s„   € ô
  Ó!€FÞÜÐ7Ó8Ð8ð .€IÛˆØ‰oˆÜ�yŠy˜œbŸg™g×&Ñ&Ùä�	‰	Ð)¨3Ô/Ü˜‹}Òñ ô Ø6¸¿¹À6Ó9JÑJóð r   c                  ó4  • [        5       n [        R                  " SU R                  5       SS/5      u  pUR                  5       nU(       d  [        R                  " S5      e[        R                  " [
        SU/5      u  p2[        UR                  5       5      $ )zß
Finds the user's home directory path as a WSL path.

raises: IOError when no mountpoint with cmd.exe is found
           ProcessExecutionError when either cmd.exe is unable to retrieve
           the user's home directory
z/initz/Czecho %USERPROFILE%z4No output from cmd.exe to show the user profile dir.z-au)r0   r   Úas_posixr   ÚProcessExecutionErrorr   r   )r/   Úhomer   Úouts       r   Ú	find_homer6   S   s|   € ô Ó
€Cô �iŠi˜ #§,¡,£.°$Ð8LÐMÓN�G€DØ�;‰;‹=€DÞÜ×(Ò(ØBó
ð 	
ô �YŠYœ U¨DÐ1Ó2�F€CÜ�C—J‘J“LÓ!Ð!r   Ú	user_homec                 óÎ   • [         R                  R                  U S5      n[         R                  R                  U5      (       d  [        R                  SU5        g[        U5      $ )z•
Returns the Windows user profile .cloud-init directory translated as a
Linux path accessible inside the current WSL instance, or None if not
found.
z.cloud-initz*cloud-init user data dir %s doesn't exist.N)r(   Úpathr-   Úisdirr+   r,   r   )r7   Úseed_dirs     r   Úcloud_init_data_dirr<   q   sH   € ô �w‰w�|‰|˜I }Ó5€HÜ�7‰7�=‰=˜×"Ñ"Ü�	‰	Ð>ÀÔIØä�HÓÐr   c                 óp   • [         R                  " 5       u  pnU(       a  UOUnSU -  U< SU< S3SU-  S/$ )zs
Return a list of candidate file names that may contain user-data
in some supported format, ordered by precedence.
r   Ú-z
.user-dataz%s-all.user-datazdefault.user-data)r	   Úget_linux_distro)r   Údistribution_idÚ
version_idÚversion_codenameÚversions        r   Úcandidate_user_data_file_namesrD      sI   € ô
 59×4IÒ4IÓ4KÑ1€OÐ!1Þ&‰jÐ,<€Gð 	˜Ñ&ã,«gÐ6à˜_Ñ,àð	ð 	r   c                   ó4   • \ rS rSrSrS\4S jrS\4S jrSr	g)	Ú
ConfigDataé“   zzModels a piece of configuration data as a dict if possible, while
retaining its raw representation alongside its file pathr9   c                 óÒ   • [         R                  " U5      U l        Xl        S U l        S[        U R                  5      :X  a&  [         R                  " U R                  5      U l        g g )Nztext/cloud-config)r	   Úload_text_fileÚrawr9   Úconfig_dictr   Ú	load_yaml)Úselfr9   s     r   Ú__init__ÚConfigData.__init__—   sN   € Ü×+Ò+¨DÓ1ˆŒØ"Œ	à+/ˆÔàÔ"7¸¿¹Ó"AÓAÜ#Ÿ~š~¨d¯h©hÓ7ˆDÕð Br   r   c                 ó   • U R                   S L$ ©N)rK   )rM   s    r   Úis_cloud_configÚConfigData.is_cloud_config    s   € Ø×Ñ tÐ+Ð+r   )rK   r9   rJ   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   rN   ÚboolrR   Ú__static_attributes__© r   r   rF   rF   “   s    † ñ@ð8˜Xô 8ð, ÷ ,r   rF   Úcloudinitdirr   c                 óŽ  • S[         0nU c  U$ [        R                  R                  U R	                  5       SU-  5      n [
        R                  " [
        R                  " U5      5      nU(       a  SU;  a(  SU SU 3n[        R                  U5        [        U5      eU$ ! [         a    [        R                  SU5         NYf = f)zT
Returns the relevant metadata loaded from cloudinit dir based on the
instance name
úinstance-idz%s.meta-dataz<No instance metadata found at %s. Using default instance-id.z Metadata at z5 does not contain instance-id key. Instead received: )ÚDEFAULT_INSTANCE_IDr(   r9   r-   r2   r	   rL   rI   ÚFileNotFoundErrorr+   r,   ÚerrorÚ
ValueError)r\   r   ÚmetadataÚmetadata_pathÚmsgs        r   Úload_instance_metadatarf   ¤   sÅ   € ð Ô2Ð3€HØÑØˆÜ—G‘G—L‘LØ×ÑÓ °-Ñ!?ó€Mð
Ü—>’>¤$×"5Ò"5°mÓ"DÓEˆö �}¨HÓ4ð ˜M˜?ð +"Ø"* ð-ð 	ô 	�	‰	�#ŒÜ˜‹oÐà€Oøô ó 
Ü�	‰	ØJØö	
ð
ús   Á *B! Â! CÃCc                 ó`  • [         R                  R                  U S5      n[         R                  R                  U5      (       d  g[	        [         R                  R                  U[
        [        5       -  5      5      nSn[         R                  R                  U5      (       a+  [        R                  SU[        U 5      5        [        U5      n[	        [         R                  R                  U[        5      5      nSn[         R                  R                  U5      (       a  [        U5      nXS4$ )z[
Read .ubuntupro user-data if present and return a tuple of agent and
landscape user-data.
z.ubuntupro/.cloud-init)NNNzYLandscape configuration found: %s. Organization policy ignores any local user-data in %s.)r(   r9   r-   r:   r   ÚLANDSCAPE_DATA_FILEr   Úisfiler+   r,   r<   rF   ÚAGENT_DATA_FILE)r7   Úpro_dirÚlandscape_pathÚlandscape_dataÚ
agent_pathÚ
agent_datas         r   Úload_ubuntu_pro_datarp   Å   sÙ   € ô �g‰g�l‰l˜9Ð&>Ó?€GÜ�7‰7�=‰=˜×!Ñ!ØäÜ
�‰�‰�WÔ1´M³OÑCÓDó€Nð €NÜ	‡w�w‡~�~�n×%Ñ%Ü�	‰	ð1àÜ 	Ó*ô		
ô $ NÓ3ˆäœ"Ÿ'™'Ÿ,™, w´Ó@ÓA€JØ€JÜ	‡w�w‡~�~�j×!Ñ!Ü 
Ó+ˆ
àÐ%Ð%r   ro   Ú	user_datac                 ó®  • U b  U R                   (       d!  Ub  UR                   (       d  gUR                   $ Ub  UR                   (       d!  U b  U R                   (       d  gU R                   $ [        U R                  5       UR                  5       /5      (       dP  [        R	                  S5        SU R
                  R                  5       < SUR
                  R                  5       < S3$ 0 nSn/ n[        UR                  [        5      (       a>  UR                  nUR                  S0 5      R                  S0 5      R                  SS5      n[        U R                  [        5      (       aÅ  U(       a  [        R	                  S	5        U R                  nU H  nXb;   a  UR                  U5        XV   X&'   M!     U(       a$  [        R	                  S
R                  U5      5        U(       aF  UR                  S0 5      R                  S5      (       a   [        R	                  SU5        X2S   S   S'   S[        R                  " U5      R                  5       -  $ )a   Merge agent.yaml data provided by Ubuntu Pro for WSL
and user data provided either by Landscape or the local user,
according to the UP4W specific rules.

When merging is not possible, provide #include directive to allow
cloud-init to merge separate parts.
NzaUnable to merge {agent_data.path} and {user_data.path}. Providing as separate user-data #include.z	#include
Ú
Ú Ú	landscapeÚclientÚtagsz.Merging both user_data and agent.yaml configs.z% agent.yaml overrides config keys: , zFLandscape client conf updated with user-data landscape.client.tags: %sz@#cloud-config
# WSL datasouce Merged agent.yaml and user_data
%s)rJ   ÚallrR   r+   r,   r9   r2   Ú
isinstancerK   ÚdictÚgetr    r-   ÚyamlÚdumpÚstrip)ro   rq   ÚmergedÚ	user_tagsÚoverridden_keysÚagentÚkeys          r   Úmerge_agent_landscape_datar„   å   sð  € ð 	Ñ J§N§NØÑ y§}§}ØØ�}‰}Ðð 	Ñ 9§=§=ØÑ¨
¯¯ØØ�~‰~Ðô �
×*Ñ*Ó,¨i×.GÑ.GÓ.IÐJ×KÑKÜ�	‰	ð8õ	
ð
 �O‰O×$Ñ$Ö&Ø�N‰N×#Ñ#Ö%ð
ð 	
ð €FØ€IØ(*€OÜ�)×'Ñ'¬×.Ñ.Ø×&Ñ&ˆà�J‰J�{ BÓ'×+Ñ+¨H°bÓ9×=Ñ=¸fÀbÓIð 	ô �*×(Ñ(¬$×/Ñ/ÞÜ�I‰IÐFÔGØ×&Ñ&ˆÛˆCØ‹}Ø×&Ñ& sÔ+Ø™*ˆF‹Kñ ö Ü�I‰Iðß™˜oÓ.ôö ˜Ÿ™ K°Ó4×8Ñ8¸×BÑBÜ�I‰Ið-àôð
 5>�;Ñ Ñ)¨&Ñ1ð 	MÜ
�)Š)�FÓ
×
!Ñ
!Ó
#ñ	$ðr   c                   ój   ^ • \ rS rSrSrSS\S\4U 4S jjjrS\S\4S jr	S\
4S	 jrS\
4S
 jrSrU =r$ )ÚDataSourceWSLi:  ÚWSLÚdistroÚpathsc                 ó4   >• [         TU ]  XX45        SU l        g )Nrt   )ÚsuperrN   r   )rM   Úsys_cfgrˆ   r‰   Úud_procÚ	__class__s        €r   rN   ÚDataSourceWSL.__init__=  s   ø€ Ü‰Ñ˜¨%Ô9ØˆÕr   r;   r   c                 ó¨  • [         R                  " U5       Vs0 s H'  o"R                  R                  5       UR                  _M)     nnU(       d  [        SU-  5      e[        U R                  5       Vs/ s H  nUR                  5       PM     nnU H%  nXcR                  5       ;   d  M  [        X6   5      s  $    [        SU-  5      es  snf s  snf )zi
Finds the most precendent of the candidate files that may contain
user-data, if any, or None otherwise.
z%s directory is emptyz6%s doesn't contain any of the expected user-data files)
r(   Úscandirr   Úcasefoldr9   r'   rD   r   Úkeysr   )rM   r;   ÚefÚexisting_filesÚfÚfolded_namesÚfilenames          r   Úfind_user_data_fileÚ!DataSourceWSL.find_user_data_fileA  sÑ   € ô 35·*²*¸XÔ2Fó
Ú2F¨B�G‰G×ÑÓ §¡Ò'Ñ2Fð 	ð 
ö ÜÐ1°HÑ<Ó=Ð=ô 4°D×4FÑ4FÔGó
âG�ð �J‰JŽLÙGð 	ð 
ó %ˆHØ×.Ñ.Ó0Õ0Ü Ñ 8Ó9Ò9ñ %ô ØDÀxÑOó
ð 	
ùò
ùò
s   ™.C
Á5Cc                 ó   • U R                  5       nU(       d  g [        [        5       5      n[        U[	        5       5      nX$R                  S5      :H  $ ! [        [        4 a)  n[        R                  S[        U5      5         S nAgS nAff = f)NFr^   z2Unable to check_instance_id from metadata file: %s)Úget_instance_idr<   r6   rf   r   r{   r'   rb   r+   ÚwarningÚstr)rM   rŒ   ÚcurrentÚdata_dirrc   Úerrs         r   Úcheck_instance_idÚDataSourceWSL.check_instance_id_  sy   € ð ×&Ñ&Ó(ˆÞØð
	Ü*¬9«;Ó7ˆHÜ-¨h¼»ÓHˆHØŸl™l¨=Ó9Ñ9Ð9øäœÐ$ó 	Ü�K‰KØDÜ�C“ôô ûð	ús   š9A ÁBÁ$BÂBc                 óT  • [         R                  " [        5      (       d  [        R	                  S[        5        g[        5       U l         [        5       n[        U5      nS nS n [        X0R
                  5      U l
        U R                  R                  S:X  a  [!        U5      u  pE Uc  Ub  [#        U R%                  U5      5      n[)        XT/5      (       d  g[+        XE5      U l        g! [         a   n[        R	                  SU5         S nAgS nAff = f! [        [        4 a)  n[        R                  S[        U5      5         S nAgS nAff = f! [        [        4 aD  nU(       a  [        R&                  O[        R                  nU" SU[        U5      5         S nANÛS nAff = f)Nz5No WSL command %s found. Cannot detect WSL datasourceFz#Unable to detect WSL datasource: %szUnable to load metadata: %sÚubuntuz+Unable to load any user-data file in %s: %sT)r   Úwhichr   r+   r,   r   r6   r'   r<   rf   rc   rb   ra   rž   rˆ   r   rp   rF   r™   ÚinfoÚanyr„   Úuserdata_raw)rM   r7   Úer;   ro   rq   r¡   Úlogs           r   Ú	_get_dataÚDataSourceWSL._get_datar  si  € Ü�zŠzœ+×&Ñ&Ü�I‰IØGÜôð Ü*›_ˆÔð	Ü!›ˆIô
 ' yÓ1ˆØ+/ˆ
Ø*.ˆ	ð	Ü2Ø×,Ñ,óˆDŒMð �;‰;×Ñ˜xÓ'Ü$8¸Ó$CÑ!ˆJð
	ØÑ  XÑ%9Ü& t×'?Ñ'?ÀÓ'IÓJ�	ô �IÐ*×+Ñ+Øä6°zÓMˆÔØøôO ó 	Ü�I‰IÐ;¸QÔ?Üûð	ûô œGÐ$ó 	Ü�I‰IÐ3´S¸³XÔ>Üûð	ûô œGÐ$ó 	Þ(”#—(’(¬c¯i©iˆCÙØ=ØÜ�C“÷ñ ûð	úsH   Á
C* Á%D Â' E Ã*
DÃ4DÄDÄEÄ'EÅEÅF'Å#:F"Æ"F')r   rc   r©   rQ   )rT   rU   rV   rW   Údsnamer
   r   rN   r   r™   rY   r¢   r¬   rZ   Ú__classcell__)rŽ   s   @r   r†   r†   :  sP   ø† Ø€Fñ ¨ð  °u÷  ð  ð
¨Hð 
¸ô 
ð<¨Dô ð&2˜4÷ 2ò 2r   r†   c                 ó8   • [         R                  " U [        5      $ rQ   )r   Úlist_from_dependsÚdatasources)Údependss    r   Úget_datasource_listr´   ®  s   € Ü×$Ò$ W¬kÓ:Ð:r   ),rX   Úloggingr(   ÚtypingÚpathlibr   r   r   r   r|   Ú	cloudinitr   r   r	   Úcloudinit.distrosr
   Úcloudinit.handlersr   Úcloudinit.helpersr   Ú	getLoggerrT   r+   r   r_   rh   rj   rž   r   r%   r0   r6   r<   rD   rF   rz   rf   rp   r„   Ú
DataSourcer†   ÚDEP_FILESYSTEMr²   r´   r[   r   r   Ú<module>r¿      sl  ðñ Fã Û 	Û Ý ß (Ñ (ã ç )Ñ )Ý $Ý 4Ý #à×Ò˜Ó!€à €à*Ð Ø$Ð Ø€ð
1�sô 
1ð˜D ™Iô ð ˜ô ð0"�8ô "ð< 8ð °¸Ñ0Bô ð°T¸#±Yô ÷(,ñ ,ð"Ø˜8Ñ$ðØ58ðà	ôðB&Øð&à
ˆ8�JÑ ¨*Ñ!5Ð5Ñ6ô&ð@RØ˜Ñ$ðRØ19¸*Ñ1EðRàˆc�]ôRôjj�G×&Ñ&ô jð^ �W×+Ñ+Ð-Ð.ð€ó;r   