__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

x[h����^�SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr SSK	J	r	J
r
 SSKJrJr SSK
JrJrJrJrJr SSKJr SSKJr SSKJrJrJrJrJrJr SS	KJ r  SS
K!J"r" \RF"\$5r%Sr&Sr'S
r(Sr)Sr*\ RV"SSSS9r,\"S5r-S\S\-4S\S\-44Sjr.\.S5r/\.S5r0SS.S\1S\ Rd4Sjjr3Sr4\.S5r5\S 5r6\.SS!S"S#.S$\1S%\7S&\\8S'\9S(\9S\Rt4S)jj5r;S*\1S+\1S,\1S\84S-jr<"S.S/5r="S0S1\>5r?"S2S35r@"S4S55rA"S6S75rB"S8S95rC\.SGS:\1S;\R�S<\\\1S=\\14S>jj5rE\.S:\1S?S@4SAj5rFSBrG"SCSD\>5rH"SESF5rIg)H�N)�contextmanager)�datetime�timezone)�sleep�time)�Callable�List�Optional�TypeVar�Union)�ElementTree)�escape)�distros�subp�
temp_utils�
url_helper�util�version)�events)�errorsz
168.63.129.16�boot-telemetryzsystem-info�
diagnostic�
compressedzazure-dsz initialize reporter for azure dsT)�name�description�reporting_enabled�T�func.�returnc�^�U4SjnU$)Nc�>�[R"TRTR[S9 T"U0UD6sSSS5 $!,(df   g=f)N�rr�parent)r�ReportEventStack�__name__�azure_ds_reporter)�args�kwargsrs  ��A/usr/lib/python3/dist-packages/cloudinit/sources/helpers/azure.py�impl�)azure_ds_telemetry_reporter.<locals>.impl*sA���
�
$�
$�����
�
�$�
�
��(��(�
�
�
�s�A�
A�)rr*s` r)�azure_ds_telemetry_reporterr-)s���)��K�c
�x�[R"5(d[S5e[R	S5 [[
55[[R"55-
n[R"/SQSS9up#SnU(aSU;aURS5S	nU(d[S
5eU[U5S--n[R"/SQSS9up#SnU(aSU;aURS5S	nU(d[S5eU[U5S--n[R"[SS[ R""U[$R&5R)5<S[ R""U[$R&5R)5<S[ R""U[$R&5R)5<3[R*5n[R,"U5 U$![an[S5UeSnAff=f![Ran[SU-5UeSnAf[an[S
U-5UeSnAff=f![Ran[SU-5UeSnAf[an[SU-5UeSnAff=f)zWReport timestamps related to kernel initialization and systemd
activation of cloud-initz1distro not using systemd, skipping boot telemetryzCollecting boot telemetryz*Failed to determine kernel start timestampN)�	systemctl�show�-p�UserspaceTimestampMonotonicT)�capture�=�z8Failed to parse UserspaceTimestampMonotonic from systemdi@Bz-Failed to get UserspaceTimestampMonotonic: %sz<Failed to parse UserspaceTimestampMonotonic from systemd: %s)r0r1zcloud-init-localr2�InactiveExitTimestampMonotonicz;Failed to parse InactiveExitTimestampMonotonic from systemdz0Failed to get InactiveExitTimestampMonotonic: %sz?Failed to parse InactiveExitTimestampMonotonic from systemd: %srz
kernel_start=z user_start=z cloudinit_activation=)r�uses_systemd�RuntimeError�LOG�debug�floatrr�uptime�
ValueErrorr�split�ProcessExecutionErrorr�ReportingEvent�BOOT_EVENT_TYPEr�
fromtimestampr�utc�	isoformat�DEFAULT_EVENT_ORIGIN�report_event)�kernel_start�e�out�_�tsm�
user_start�cloudinit_activation�evts        r)�get_boot_telemetryrP5s������!�!��N�O�O��I�I�)�*�P��T�V�}�u�T�[�[�]�';�;������F��
������3�#�:��)�)�C�.��#�C���J��
�"�U�3�Z�'�%9�:�
�����
��	
������3�#�:��)�)�C�.��#�C���M��
� ,�u�S�z�G�/C�D���
�
���
�"�"�<����>�H�H�J��"�"�:�x�|�|�<�F�F�H��"�"�$�h�l�l�
��i�k�
�		
�	�#�#��C�������J��S�P��G�H�a�O��P��$�%�%���;�a�?�
��	�����J�Q�N�
��	����2�%�%���>��B�
��	�����M��
�
��	���sa�2H�/AH.�AI5�
H+�H&�&H+�.I2�I�
I2�I-�-I2�5J9�	J�
J9�%J4�4J9c�F�[R"5n[R"[SS[
R"5<SUS<SUS<SUSS	<S
USS<SUSS
<SUS<3[R5n[R"U5 U$)z%Collect and report system informationzsystem informationzcloudinit_version=z, kernel_version=�releasez
, variant=�variantz, distro_name=�distrz, distro_version=r6z	, flavor=�z, python_version=�python)	r�system_inforrA�SYSTEMINFO_EVENT_TYPEr�version_stringrFrG)�inforOs  r)�get_system_infor[�s�������D�
�
�
���

�"�"�$���O���O���L��O���L��O���L��O���N�	
�	�#�#��C�"������Jr.��logger_func�msgc��[U5(aU"U5 [R"[SU[R5n[R
"US1S9 U$)zReport a diagnostic eventzdiagnostic message�log��excluded_handler_types)�callablerrA�DIAGNOSTIC_EVENT_TYPErFrG)r^r]rOs   r)�report_diagnostic_eventre�sT�������C��
�
�
�����#�#�	�C�����U�G�<��Jr.c�.�[R"[R"U55nSUR	S5S.n[
R"[U[R"U5[
R5n[
R"U1SkS9 U$)zReport a compressed eventzgz+b64�ascii)�encoding�data>r`�print�webhookra)�base64�encodebytes�zlib�compress�decoderrA�COMPRESSED_EVENT_TYPE�json�dumpsrFrG)�
event_name�
event_content�compressed_data�
event_datarOs     r)�report_compressed_eventrx�s}���(�(����}�)E�F�O���&�&�w�/��J��
�
����
�
�:���#�#�	�C�����$?��
�Jr.c���[RS5 [R"S/SSS9up[SU5 g![a.n[S[
U5-[RS9 SnAgSnAff=f)	zReport dmesg to KVP.zDumping dmesg log to KVP�dmesgFT)rpr4z$Exception when dumping dmesg log: %sr\N)r:r;rrx�	Exceptionre�repr�warning)rJrK�exs   r)�report_dmesg_to_kvpr�sa���I�I�(�)�
����G�9�U�D�A������-���
��2�T�"�X�=����	
��
�s�%=�
A5�$A0�0A5c#�# �[R"5n[R"[RR	U55 Sv� [R"U5 g![R"U5 f=f7f�N)�os�getcwd�chdir�path�
expanduser)�newdir�prevdirs  r)�cdr��sK����i�i�k�G��H�H�R�W�W�
�
��
'�(��
�
�����������s�A	B�A'�B�'A?�?B��)ri�retry_sleep�timeout_minutes�url�headersrir�r�c	��US-[5-nSnSnU(dUS-
n[R"XUSS9n[	S
X4-[RS9 U$![Ra]n[	SXX�R
UR4-[RS9 [5U-U:�dS	[U5;aeSnAOSnAff=f[U5 U(dM�N�)z�Readurl wrapper for querying wireserver.

:param retry_sleep: Time to sleep before retrying.
:param timeout_minutes: Retry up to specified number of minutes.
:raises UrlError: on error fetching data.
�<rNr6)r�r�)r�ri�timeoutzdFailed HTTP request with Azure endpoint %s during attempt %d with exception: %s (code=%r headers=%r)r\zNetwork is unreachablez@Successful HTTP request with Azure endpoint %s after %d attempts)rr�readurl�UrlErrorre�coder�r:r;�strr)	r�r�rir�r�r��attempt�responserIs	         r)�http_with_retriesr��s�����"�T�V�+�G��G��H���1���	�!�)�)��4���H�
�,�	���	'��I�I��
�O��5�"�"�	�#�E���F�F�A�I�I�6�7� �I�I�	
����$��/�+�s�1�v�5��6��	��&	�k��5�hs�A�C�+AC�C�username�hostname�
disableSshPwdc�p�[R"S5nURXUS9nURS5$)Na.        <ns0:Environment xmlns:ns0="http://schemas.dmtf.org/ovf/environment/1"
         xmlns:ns1="http://schemas.microsoft.com/windowsazure"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <ns1:ProvisioningSection>
            <ns1:Version>1.0</ns1:Version>
            <ns1:LinuxProvisioningConfigurationSet>
              <ns1:ConfigurationSetType>LinuxProvisioningConfiguration
              </ns1:ConfigurationSetType>
              <ns1:UserName>{username}</ns1:UserName>
              <ns1:DisableSshPasswordAuthentication>{disableSshPwd}
              </ns1:DisableSshPasswordAuthentication>
              <ns1:HostName>{hostname}</ns1:HostName>
            </ns1:LinuxProvisioningConfigurationSet>
          </ns1:ProvisioningSection>
          <ns1:PlatformSettingsSection>
            <ns1:Version>1.0</ns1:Version>
            <ns1:PlatformSettings>
              <ns1:ProvisionGuestAgent>true</ns1:ProvisionGuestAgent>
            </ns1:PlatformSettings>
          </ns1:PlatformSettingsSection>
        </ns0:Environment>
        )r�r�r��utf-8)�textwrap�dedent�format�encode)r�r�r��OVF_ENV_TEMPLATE�rets     r)�build_minimal_ovfr�sE�� ���	���2�
!�
!��M�"��C��:�:�g��r.c�|�\rSrSrSSS.rSrSS\R4SjjrS
S	\	\
S\R4S
jjrSrg)�AzureEndpointHttpClienti>�WALinuxAgentz
2012-11-30)zx-ms-agent-namezx-ms-versionc��SUS.Ulg)N�DES_EDE3_CBC)zx-ms-cipher-namez!x-ms-guest-agent-public-x509-cert��extra_secure_headers)�self�certificates  r)�__init__� AzureEndpointHttpClient.__init__Ds�� .�1<�%
��!r.rc��URnU(a5URR5nURUR5 [	XS9$)N)r�)r��copy�updater�r�)r�r��securer�s    r)�get�AzureEndpointHttpClient.getJs=���,�,����l�l�'�'�)�G��N�N�4�4�4�5� ��6�6r.Nric��URnUb+URR5nURU5 [XUS9$)N)rir�)r�r�r�r�)r�r�ri�
extra_headersr�s     r)�post�AzureEndpointHttpClient.postQs>���,�,���$��l�l�'�'�)�G��N�N�=�)� ���A�Ar.r�)F�NN)
r%�
__module__�__qualname__�__firstlineno__r�r�r�UrlResponser�r
�bytesr��__static_attributes__r,r.r)r�r�>sU��)�$��G�

�7�
�(>�(>�7�@D�B�!�%��B�	�	�	�B�Br.r�c��\rSrSrSrSrg)�InvalidGoalStateXMLExceptioni[z9Raised when GoalState XML is invalid or has missing data.r,N)r%r�r�r��__doc__r�r,r.r)r�r�[s��Cr.r�c	�D�\rSrSrS
S\\\4S\S\SS4Sjjr	Sr
S	rg)�	GoalStatei_�unparsed_xml�azure_endpoint_client�need_certificaterNc���X l[R"U5UlURS5Ul	URS5Ul
URS5UlSH7n[X5bMSU-n[U[RS9 [U5e SUlURS	5nUbnU(af[R "S
S["S9 URR%US
S9R&UlURc[S5eSSS5 ggg![Ra!n[SU-[RS9 eSnAff=f!,(df   g=f)a@Parses a GoalState XML string and returns a GoalState object.

@param unparsed_xml: string representing a GoalState XML.
@param azure_endpoint_client: instance of AzureEndpointHttpClient.
@param need_certificate: switch to know if certificates is needed.
@return: GoalState object representing the GoalState XML string.
z!Failed to parse GoalState XML: %sr\Nz./Container/ContainerIdz4./Container/RoleInstanceList/RoleInstance/InstanceIdz
./Incarnation)�container_id�instance_id�incarnationzMissing %s in GoalState XMLzD./Container/RoleInstanceList/RoleInstance/Configuration/Certificateszget-certificates-xmlzget certificates xmlr"T)r�z/Azure endpoint returned empty certificates xml.)r��ET�
fromstring�root�
ParseErrorrer:r}�_text_from_xpathr�r�r��getattrr��certificates_xmlrr$r&r��contents)r�r�r�r�rI�attrr^r�s        r)r��GoalState.__init__`sx��&;�"�	��
�
�l�3�D�I�!�1�1�2K�L����0�0�B�
��� �0�0��A���B�D��t�"�*�3�d�:��'�����E�2�3�7�7�	C�!%����#�#�
*�
���?�/��(�(�+�2�(��
)-�(B�(B�(F�(F���)G�)��(��%��(�(�0�6�I���1��� 0�?��1�}�}�	�#�3�a�7��K�K�
�
��	��2��s$�D,�AE$�,E!�E�E!�$
E2c�X�URRU5nUbUR$gr�)r��find�text)r��xpath�elements   r)r��GoalState._text_from_xpath�s'���)�)�.�.��'�����<�<��r.)r�r�r�r�r�r�)T)r%r�r�r�rr�r�r��boolr�r�r�r,r.r)r�r�_sA��
"&�	5��C��J�'�5� 7�5��	5�

�5�nr.r�c���\rSrSrSSS.rSrSr\S5r\RS5r\
S	5r\\
S
55r
\
S5r\
S5r\
S
5r\
S5rSrg)�OpenSSLManageri�zTransportPrivate.pemzTransportCert.pem)�private_keyr�c�f�[R"5UlSUlUR	5 gr�)r�mkdtemp�tmpdir�_certificate�generate_certificate�r�s r)r��OpenSSLManager.__init__�s&�� �(�(�*��� ����!�!�#r.c�D�[R"UR5 gr�)r�del_dirr�r�s r)�clean_up�OpenSSLManager.clean_up�s�����T�[�[�!r.c��UR$r��r�r�s r)r��OpenSSLManager.certificate�s��� � � r.c��Xlgr�r�)r��values  r)r�r��s��!�r.c�,�[RS5 URb[RS5 g[UR5 [
R
"SSSSSSS	S
SSS
URSSURS/5 Sn[R"URS5R5HnSU;dMXR5-
nM XlSSS5 [RS5 g!,(df   N$=f)Nz7Generating certificate for communication with fabric...zCertificate already generated.�openssl�reqz-x509z-nodesz-subjz/CN=LinuxTransportz-days�32768z-newkeyzrsa:3072z-keyoutr�z-outr���CERTIFICATEzNew certificate generated.)r:r;r�r�r�r�certificate_namesr�load_text_file�
splitlines�rstrip)r�r��lines   r)r��#OpenSSLManager.generate_certificate�s����	�	�K�L����'��I�I�6�7��
����_��I�I������(�������*�*�=�9���*�*�=�9��
�$�K��+�+��&�&�}�5���j�l���!��,��;�;�=�0�K�	�
 +��3�4	�	�	�.�/�5�_�s�A9D�D�
Dc�>�SSSU/n[R"X!S9up4U$)Nr��x509z-noout�ri)r)�action�cert�cmd�resultrKs     r)�_run_x509_action�OpenSSLManager._run_x509_action�s'���&�(�F�3���I�I�c�-�	���
r.c�^�URSU5n/SQn[R"X2S9upEU$)Nz-pubkey)z
ssh-keygenz-iz-m�PKCS8z-fz
/dev/stdinr)rr)r�r��pub_key�
keygen_cmd�ssh_keyrKs      r)�_get_ssh_key_from_cert�%OpenSSLManager._get_ssh_key_from_cert�s.���'�'�	�;�?��L�
��Y�Y�z�8�
���r.c��URSU5nURS5nX#S-SRS5nSRU5$)z�openssl x509 formats fingerprints as so:
'SHA1 Fingerprint=07:3E:19:D1:4D:1C:79:92:24:C6:A0:FD:8D:DA:\
B6:A8:BF:27:D4:73\n'

Azure control plane passes that fingerprint as so:
'073E19D14D1C799224C6A0FD8DDAB6A8BF27D473'
z-fingerprintr5r6����:r�)rr�r?�join)r�r��raw_fp�eq�octetss     r)�_get_fingerprint_from_cert�)OpenSSLManager._get_fingerprint_from_cert�sK���&�&�~�{�C��
�[�[��
���Q���$�*�*�3�/���w�w�v��r.c�x�[R"U5RS5nURnSSSSSUR	S5/n[UR5 [R"SR"S
0URD6S	S
RU5S9upVSSS5 U$!,(df   W$=f)z�Decrypt the certificates XML document using the our private key;
return the list of certs and private keys contained in the doc.
z.//DatasMIME-Version: 1.0s<Content-Disposition: attachment; filename="Certificates.p7m"s?Content-Type: application/x-pkcs7-mime; name="Certificates.p7m"s!Content-Transfer-Encoding: base64r.r�zuopenssl cms -decrypt -in /dev/stdin -inkey {private_key} -recip {certificate} | openssl pkcs12 -nodes -password pass:T�
)�shellriNr,)r�r�r�r�r�r�r�rr�r�r)r�r��tag�certificates_content�linesrJrKs       r)�_decrypt_certs_from_xml�&OpenSSLManager._decrypt_certs_from_xml�s���
�m�m�,�-�2�2�9�=��"�x�x�� �K�N�0�� �'�'��0�

������_��Y�Y�#�#)�6�*�D�,0�,B�,B�D���Z�Z��&��F�C���
��_��
�s
�AB*�*
B9c�n�URU5n/n0nUR5H�nURU5 [R"SU5(a/nM4[R"SU5(dMRSRU5nUR
U5nURU5nXtU'/nM� U$)zxGiven the Certificates XML document, return a dictionary of
fingerprints and associated SSH keys derived from the certs.z[-]+END .*?KEY[-]+$z[-]+END .*?CERTIFICATE[-]+$�
)rr��append�re�matchrrr)	r�r�rJ�current�keysr�r�r�fingerprints	         r)�parse_certificates�!OpenSSLManager.parse_certificatess����*�*�+;�<�������N�N�$�D��N�N�4� ��x�x�.��5�5������8�$�?�?�"�i�i��0���5�5�k�B��"�=�=�k�J��$+�[�!���%��r.)r�r�r�N)r%r�r�r�r�r�r��propertyr��setterr-r��staticmethodrrrrr'r�r,r.r)r�r��s���-�*���
$�
"��!��!����"��"�!�0�!�0�B� ��!���
!��!��!��!��!��!��0!��!�r.r�c��\rSrSr\R
"S5r\R
"S5rSrSr	Sr
SrS\S	\
S
\SS4S
jr\SSj5r\S\SS4Sj5rSS\S\S\S\S\4
Sjjr\S\SS4Sj5rSrg)�GoalStateHealthReporteri a�        <?xml version="1.0" encoding="utf-8"?>
        <Health xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <GoalStateIncarnation>{incarnation}</GoalStateIncarnation>
          <Container>
            <ContainerId>{container_id}</ContainerId>
            <RoleInstanceList>
              <Role>
                <InstanceId>{instance_id}</InstanceId>
                <Health>
                  <State>{health_status}</State>
                  {health_detail_subsection}
                </Health>
              </Role>
            </RoleInstanceList>
          </Container>
        </Health>
        z�        <Details>
          <SubStatus>{health_substatus}</SubStatus>
          <Description>{health_description}</Description>
        </Details>
        �Ready�NotReady�ProvisioningFailedi�
goal_stater��endpointrNc�(�XlX lX0lg)a�Creates instance that will report provisioning status to an endpoint

@param goal_state: An instance of class GoalState that contains
    goal state info such as incarnation, container id, and instance id.
    These 3 values are needed when reporting the provisioning status
    to Azure
@param azure_endpoint_client: Instance of class AzureEndpointHttpClient
@param endpoint: Endpoint (string) where the provisioning status report
    will be sent to
@return: Instance of class GoalStateHealthReporter
N)�_goal_state�_azure_endpoint_client�	_endpoint)r�r1r�r2s    r)r�� GoalStateHealthReporter.__init__Fs��"&��&;�#�!�r.c��URURRURRURRUR
S9n[RS5 URUS9 [RS5 g![a!n[SU-[RS9 eSnAff=f)N)r�r�r��statusz Reporting ready to Azure fabric.��documentz#exception while reporting ready: %sr\zReported ready to Azure fabric.)
�build_reportr4r�r�r��PROVISIONING_SUCCESS_STATUSr:r;�_post_health_reportr{re�errorrZ)r�r;rIs   r)�send_ready_signal�)GoalStateHealthReporter.send_ready_signal[s����$�$��(�(�4�4��)�)�6�6��(�(�4�4��3�3�	%�
��	�	�	�4�5�	��$�$�h�$�7�	���2�3���	�#�5��9��I�I�
�
��	�s�/B�
B?�B:�:B?rc	�v�URURRURRURRUR
URUS9nURUS9 [RS5 g![a#nSU-n[U[RS9 eSnAff=f)N)r�r�r�r9�	substatusrr:z%exception while reporting failure: %sr\z!Reported failure to Azure fabric.)
r<r4r�r�r��PROVISIONING_NOT_READY_STATUS�PROVISIONING_FAILURE_SUBSTATUSr>r{rer:r?r})r�rr;rIr^s     r)�send_failure_signal�+GoalStateHealthReporter.send_failure_signalos����$�$��(�(�4�4��)�)�6�6��(�(�4�4��5�5��9�9�#�
%�
��	��$�$�h�$�7�	���7�8���	�9�A�=�C�#�C�S�Y�Y�?���	�s�&B�
B8�B3�3B8r�r�r�r9c�4�SnUb9URR[U5[USUR5S9nURR[[U55[U5[U5[U5US9nUR
S5$)Nr�)�health_substatus�health_description)r�r�r��
health_status�health_detail_subsectionr�)�%HEALTH_DETAIL_SUBSECTION_XML_TEMPLATEr�r�"HEALTH_REPORT_DESCRIPTION_TRIM_LEN�HEALTH_REPORT_XML_TEMPLATEr�r�)	r�r�r�r�r9rCr�
health_detail�
health_reports	         r)r<�$GoalStateHealthReporter.build_report�s����
�� � �F�F�M�M�!'�	�!2�#)�� I�$�"I�"I�J�$�N��M��7�7�>�>��s�;�/�0���-��{�+� ��.�%2�?�
�
��#�#�G�,�,r.r;c���[S5 [RS5 SRUR5nUR
R
UUSS0S9 [RS5 g)Nrz&Sending health report to Azure fabric.zhttp://{}/machine?comp=healthzContent-Typeztext/xml; charset=utf-8)rir�z/Successfully sent health report to Azure fabric)rr:r;r�r6r5r�)r�r;r�s   r)r>�+GoalStateHealthReporter._post_health_report�sc��(	�a���	�	�:�;�-�4�4�T�^�^�D���#�#�(�(���)�+D�E�	)�	
�
	�	�	�C�Dr.)r5r6r4)rNr�)r%r�r�r�r�r�rOrMr=rDrErNr�r�r�r�r-r@rFr�r<r>r�r,r.r)r-r- s
��!)���	�"��,-5�O�O�	�-�)�#*��$.�!�%9�"�),�&�"��"� 7�"��	"�

�"�*!�4�!�4�&!�9�s�9�t�9�!�9�0��-��-��-��	-�
�-�
�-�8!�E�E�E�d�E�!�Er.r-c�T�\rSrSrS\4SjrSr\S\RSS4Sj5r
\SS\RS\\\4S	jj5r
\S
\SS4Sj5r\S\S\4S
j5r\S\4Sj5r\S\\\4S\S\4Sj5r\S\S\S\4Sj5r\S\S\S\4Sj5rSrg)�WALinuxAgentShimi�r2c�,�XlSUlSUlgr�)r2�openssl_managerr�)r�r2s  r)r��WALinuxAgentShim.__init__�s�� �
�9=���HL��"r.c�T�URbURR5 ggr�)rXr�r�s r)r��WALinuxAgentShim.clean_up�s%�����+�� � �)�)�+�,r.�distrorNc��[RS5 URU5 g![a%n[	SU-[R
S9 SnAgSnAff=f)NzEjecting the provisioning isoz(Failed ejecting the provisioning iso: %sr\)r:r;�eject_mediar{rer?)r��iso_devr\rIs    r)�	eject_iso�WALinuxAgentShim.eject_iso�sI���	�	�1�2�	����w�'���	�#�:�Q�>��I�I�
��	�s�)�
A�A�Ac��SnURc(Ub%[5UlURRnURc[	U5UlURUSLS9nSnUbUR
XR5n[XPRUR5nUbURX1S9 UR5 U$)a�Gets the VM's GoalState from Azure, uses the GoalState information
to report ready/send the ready signal/provisioning complete signal to
Azure, and then uses pubkey_info to filter and obtain the user's
pubkeys from the GoalState.

@param pubkey_info: List of pubkey values and fingerprints which are
    used to filter and obtain the user's pubkey values from the
    GoalState.
@return: The list of user's authorized pubkey values.
N�r�)r\)rXr�r�r�r��_fetch_goal_state_from_azure�_get_user_pubkeysr-r2r`r@)r�r\�pubkey_infor_�http_client_certificater1�ssh_keys�health_reporters        r)�"register_with_azure_and_fetch_data�3WALinuxAgentShim.register_with_azure_and_fetch_data�s���#'�����'�K�,C�#1�#3�D� �&*�&:�&:�&F�&F�#��%�%�-�)@�'�*�D�&��6�6�4�D�@�7�
�
����"��-�-�j�F�H�1��2�2�D�M�M�
�����N�N�7�N�2��)�)�+��r.rc��URc[S5UlURSS9n[X RUR5nURUS9 g)z�Gets the VM's GoalState from Azure, uses the GoalState information
to report failure/send provisioning failure signal to Azure.

@param: user visible error description of provisioning failure.
NFrc�r)r�r�rdr-r2rF)r�rr1ris    r)�&register_with_azure_and_report_failure�7WALinuxAgentShim.register_with_azure_and_report_failure�s\���%�%�-�)@��)F�D�&��6�6��6�N�
�1��2�2�D�M�M�
��	�+�+��+�Dr.r�c�D�UR5nURX!5$)z�Fetches the GoalState XML from the Azure endpoint, parses the XML,
and returns a GoalState object.

@param need_certificate: switch to know if certificates is needed.
@return: GoalState object representing the GoalState XML
)�"_get_raw_goal_state_xml_from_azure�_parse_raw_goal_state_xml)r�r��unparsed_goal_state_xmls   r)rd�-WALinuxAgentShim._fetch_goal_state_from_azures)��#'�"I�"I�"K���-�-�#�
�	
r.c��[RS5 SRUR5n[R
"SS[S9 URRU5nSSS5 [RS	5 WR$!,(df   N/=f![a!n[SU-[RS9 eSnAff=f)
zrFetches the GoalState XML from the Azure endpoint and returns
the XML as a string.

@return: GoalState XML string
zRegistering with Azure...z!http://{}/machine/?comp=goalstatezgoalstate-retrievalzretrieve goalstater"Nz9failed to register with Azure and fetch GoalState XML: %sr\z#Successfully fetched GoalState XML.)r:rZr�r2rr$r&r�r�r{rer}r;r�)r�r�r�rIs    r)rq�3WALinuxAgentShim._get_raw_goal_state_xml_from_azures���	���,�-�1�8�8����G��
	��(�(�*�0�(��
 �5�5�9�9�#�>���	�	�	�7�8�� � � �����	�#�K����K�K�
�

��
	�s5�B"�B�(B"�
B�B"�B"�"
C
�,C�C
rsc�8�[UURU5nSR
SUR-SUR-SUR-/5n[U[RS9 U$![a!n[SU-[R
S9 eSnAff=f)z�Parses a GoalState XML string and returns a GoalState object.

@param unparsed_goal_state_xml: GoalState XML string
@param need_certificate: switch to know if certificates is needed.
@return: GoalState object representing the GoalState XML
z"Error processing GoalState XML: %sr\Nz, zGoalState XML container id: %szGoalState XML instance id: %szGoalState XML incarnation: %s)r�r�r{rer:r}rr�r�r�r;)r�rsr�r1rIr^s      r)rr�*WALinuxAgentShim._parse_raw_goal_state_xml2s���	�"�'��*�*� ��J��i�i�0�:�3J�3J�J�/�*�2H�2H�H�/�*�2H�2H�H�
�
��	 �����;�����	�#�4�q�8��K�K�
�
��	�s�A.�.
B�8B�Br1rfc���/nURb[UbXURbK[RS5 URR	UR5nURXB5nU$)a�Gets and filters the VM admin user's authorized pubkeys.

The admin user in this case is the username specified as "admin"
when deploying VMs on Azure.
See https://docs.microsoft.com/en-us/cli/azure/vm#az-vm-create.
cloud-init expects a straightforward array of keys to be dropped
into the admin user's authorized_keys file. Azure control plane exposes
multiple public keys to the VM via wireserver. Select just the
admin user's key(s) and return them, ignoring any other certs.

@param goal_state: GoalState object. The GoalState object contains
    a certificate XML, which contains both the VM user's authorized
    pubkeys and other non-user pubkeys, which are used for
    MSI and protected extension handling.
@param pubkey_info: List of VM user pubkey dicts that were previously
    obtained from provisioning data.
    Each pubkey dict in this list can either have the format
    pubkey['value'] or pubkey['fingerprint'].
    Each pubkey['fingerprint'] in the list is used to filter
    and obtain the actual pubkey value from the GoalState
    certificates XML.
    Each pubkey['value'] requires no further processing and is
    immediately added to the return list.
@return: A list of the VM user's authorized pubkey values.
z/Certificate XML found; parsing out public keys.)r�rXr:r;r'�_filter_pubkeys)r�r1rfrh�keys_by_fingerprints     r)re�"WALinuxAgentShim._get_user_pubkeysTsl��:���'�'�3��'��$�$�0��I�I�G�H�"&�"6�"6�"I�"I��+�+�#���+�+�,?�M�H��r.r{c�"�/nUH�nSU;a US(aURUS5 M)SU;aAUS(a7USnX@;aURX5 MX[RSU5 Mp[RSU5 M� U$)a�Filter and return only the user's actual pubkeys.

@param keys_by_fingerprint: pubkey fingerprint -> pubkey value dict
    that was obtained from GoalState Certificates XML. May contain
    non-user pubkeys.
@param pubkey_info: List of VM user pubkeys. Pubkey values are added
    to the return list without further processing. Pubkey fingerprints
    are used to filter and obtain the actual pubkey values from
    keys_by_fingerprint.
@return: A list of the VM user's authorized pubkey values.
r�r&zIovf-env.xml specified PublicKey fingerprint %s not found in goalstate XMLzFovf-env.xml specified PublicKey with neither value nor fingerprint: %s)r!r:r})r{rfr%�pubkeyr&s     r)rz� WALinuxAgentShim._filter_pubkeys~s�����!�F��&� �V�G�_����F�7�O�,��&�(�V�M�-B�$�]�3���5��K�K� 3� @�A��K�K�8�#�����0���"�(�r.)r�r2rXr�)r%r�r�r�r�r�r�r-r�Distror`r
r	rjrnr�r�rdr�rqrrr�listrer+�dictrzr�r,r.r)rVrV�se��M��M�
,�!������D��!��!�@D�#��n�n�#�	�$�s�)�	�#�!�#�J!�E�#�E�$�E�!�E�!�
� $�
�	�
�!�
�!�!�E�!�!�!�4!��!&�s�E�z�!2����
�	�!��B!�'�#�'�26�'�	
�'�!�'�R�!�T�!��!��!��!r.rVr2r\rfr_c��[US9nURXUS9UR5 $!UR5 f=f)N�r2)r\rfr_)rVrjr�)r2r\rfr_�shims     r)�get_metadata_from_fabricr��s@���X�.�D���6�6��G�7�
�	
�
�
����
�
��s�+�=r?zerrors.ReportableErrorc��[US9nUR5nURUS9 UR5 g!UR5 f=f)Nr�rm)rV�as_encoded_reportrnr�)r2r?r�rs    r)�report_failure_to_fabricr��sC���X�.�D��)�)�+�K���3�3��3�L��
�
����
�
��s	�;�A
c�p�[SU-[RS9 [SU-[RS9 g)Nzdhclient output stream: %sr\zdhclient error stream: %s)rer:r;)rJ�errs  r)�dhcp_log_cbr��s0���$�s�*��	�	���#�c�)�s�y�y�r.c��\rSrSrSrg)�NonAzureDataSourcei�r,N)r%r�r�r�r�r,r.r)r�r��s��r.r�c��\rSrSrSSS.rSSSSSSSSSS.	S\\S	\\S
\\S\\S\\S
\\	\
S\S\\S\SS4SjjrS\4Sjr\
S\SS4Sj5rS!S\S\S\4SjjrS"S\S\S\S\4SjjrSrSrSrS rg)#�	OvfEnvXmli�z)http://schemas.dmtf.org/ovf/environment/1z)http://schemas.microsoft.com/windowsazure)�ovf�waNF�	r��passwordr��custom_data�disable_ssh_password_auth�public_keys�preprovisioned_vm�preprovisioned_vm_type�provision_guest_proxy_agentr�r�r�r�r�r�r�r�r�rc	��XlX lX0lX@lXPlU=(d /UlXplX�lX�lgr�r�)
r�r�r�r�r�r�r�r�r�r�s
          r)r��OvfEnvXml.__init__�s>��!�
� �
� �
�&��)B�&�'2�'8�b���!2��&<�#�+F�(r.c�4�URUR:H$r�)�__dict__)r��others  r)�__eq__�OvfEnvXml.__eq__�s���}�}����.�.r.�ovf_env_xmlc�>�[R"U5nURSUR5c[S5e[5nURU5 URU5 U$![Ran[R"US9UeSnAff=f)z�Parser for ovf-env.xml data.

:raises NonAzureDataSource: if XML is not in Azure's format.
:raises errors.ReportableErrorOvfParsingException: if XML is
        unparsable or invalid.
)�	exceptionNz./wa:ProvisioningSectionz=Ignoring non-Azure ovf-env.xml: ProvisioningSection not found)r�r�r�r�"ReportableErrorOvfParsingExceptionr��
NAMESPACESr�r��&_parse_linux_configuration_set_section� _parse_platform_settings_section)�clsr�r�rI�instances     r)�
parse_text�OvfEnvXml.parse_text�s���	P��=�=��-�D�
�9�9�/����@�H�$�O��
��;���7�7��=��1�1�$�7�����}�}�	P��;�;�a�H�a�O��	P�s�A.�.B�B�Br�required�	namespacec�@�URSU<SU<3[R5nU(d8SU-n[R	U5 U(a[
R"U5eg[U5S:�a$[
R"SU[U54-5eUS$)Nz./r�missing configuration for %rr6�*multiple configuration matches for %r (%d)r)�findallr�r�r:r;r�!ReportableErrorOvfInvalidMetadata�len)r��noderr�r��matchesr^s       r)�_find�OvfEnvXml._finds����,�,�"�D�)�9�+?�+?�
���0�4�7�C��I�I�c�N���>�>�s�C�C��
��\�A�
��:�:�<���W��&�'��
�
�q�z�r.�
decode_base64�
parse_boolc��URSU-[R5nU(d9SU-n[R	U5 U(a[
R"U5eU$[U5S:�a$[
R"SU[U54-5eUSRn	U	cUn	U(a6U	b3[R"SRU	R555n	U(a[R"U	5n	U	$)Nz./wa:r�r6r�rr�)r�r�r�r:r;rr�r�r�rl�	b64decoderr?r�translate_bool)
r�r�rr�r�r��defaultr�r^r�s
          r)�_parse_property�OvfEnvXml._parse_propertys����,�,�w��~�y�/C�/C�D���0�4�7�C��I�I�c�N���>�>�s�C�C��N��w�<�!���:�:�<���W��&�'��
�
��
�����=��E��U�.��$�$�R�W�W�U�[�[�]�%;�<�E���'�'��.�E��r.c�J�URUSSS9nURUSSS9nURUSSSS9UlURUSSS9UlURUS	SS9UlURUS
SS9UlURUSSSS9UlURU5 g)
N�ProvisioningSectionT�r��!LinuxProvisioningConfigurationSet�
CustomDataF)r�r��UserName�UserPassword�HostName� DisableSshPasswordAuthentication)r�r�)r�r�r�r�r�r�r��_parse_ssh_section)r�r��provisioning_section�
config_sets    r)r��0OvfEnvXml._parse_linux_configuration_set_section@s���#�z�z��'�$� *� 
���Z�Z� �/�� �
�
� �/�/�����	0�
����,�,��
�T�-�
��
��,�,����-�
��
��,�,��
�T�-�
��
�*.�)=�)=��.���	*>�*
��&�	
���
�+r.c���URUSSS9nURUSSS9nURUSSSSS9UlURUSSS9UlURUS	SSSS9Ulg)
N�PlatformSettingsSectionTr��PlatformSettings�PreprovisionedVmF)r�r�r��PreprovisionedVMType�ProvisionGuestProxyAgent)r�r�r�r�r�)r�r��platform_settings_section�platform_settingss    r)r��*OvfEnvXml._parse_platform_settings_sectionbs���$(�J�J��+�d�%/�%
�!�!�J�J�%�'9�D�'�
��"&�!5�!5������"6�"
���'+�&:�&:��"��';�'
��#�
,0�+?�+?��&����,@�,
��(r.c�^�/UlURUSSS9nUcgURUSSS9nUcgURS[R5HXnURUSSS9nURUSSS9nURUSS	SS
9nUUUS.nURR
U5 MZ g)N�SSHFr��
PublicKeysz./wa:PublicKey�Fingerprint�Path�Valuer�)r�r�)r&r�r�)r�r�r�r�r�r�r!)	r�r��ssh_section�public_keys_section�
public_keyr&r�r�rs	         r)r��OvfEnvXml._parse_ssh_section~s�������j�j��U�U�j�C�����"�j�j����)�
���&��-�5�5��i�2�2�
�J��.�.��M�E�/��K��'�'�
�F�U�'�K�D��(�(��G�R�%�)��E� +����G�

���#�#�G�,�
r.)	r�r�r�r�r�r�r�r�r�)r�)FFN)r%r�r�r�r�r
r�r�r�r	r�r�r��classmethodr�r�r�r�r�r�r�r,r.r)r�r��s`��:�9��J�#'�"&�"&�'+�48�,0�"'�04�,1�G��3�-�G��3�-�	G�
�3�-�G��e�_�
G�$,�D�>�G��d�4�j�)�G� �G�!)��
�G�&*�G�
�G�./�t�/���S��[����:�����	�
��:$� ��#��#��	#�
�#��
#�J ,�D
�8-r.r�r�)Jrlrr�loggingr�r"r�rn�
contextlibrrrrr�typingrr	r
rr�	xml.etreer
r��xml.sax.saxutilsr�	cloudinitrrrrrr�cloudinit.reportingr�cloudinit.sources.azurer�	getLoggerr%r:�DEFAULT_WIRESERVER_ENDPOINTrBrXrdrqr$r&rr-rPr[r�rArerxrr�r�r��intr�r�r�r�r{r�r�r�r-rVr�r�r�r�r�r�r,r.r)�<module>r�s���
���	�	���%�'��;�;�'�#�J�J�&�*�
����!��.��"��%��$��$���+�+�	�2�����C�L��	�h�s�A�v�&6�	�8�C��F�;K�	��R��R�j����6"��	������$�*�

��

������
!���
3�	�3��3��5�/�	3�
�3��
3����3��3�l��� ��14��
��DB�B�:D�9�D�<�<�~��D[E�[E�|b�b�J�(,�!�	����N�N���$�s�)�$���c�]�	�����s��3K�����	��	�P-�P-r.

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 165 B 0644
akamai.cpython-313.pyc File 1.93 KB 0644
aliyun.cpython-313.pyc File 5.91 KB 0644
azure.cpython-313.pyc File 46.53 KB 0644
cloudsigma.cpython-313.pyc File 4.71 KB 0644
digitalocean.cpython-313.pyc File 8.25 KB 0644
ec2.cpython-313.pyc File 9.33 KB 0644
hetzner.cpython-313.pyc File 1.14 KB 0644
netlink.cpython-313.pyc File 13.02 KB 0644
openstack.cpython-313.pyc File 28.2 KB 0644
upcloud.cpython-313.pyc File 6.95 KB 0644
vultr.cpython-313.pyc File 8.2 KB 0644
Filemanager