HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/ec2/__pycache__/decryptpassword.cpython-36.pyc
3

�T_��@snddlZddlZddlZddlZddlmZddlmZddlm	Z	ej
e�ZdZ
dd�ZGdd	�d	e	�ZdS)
�N)�six)�model)�BaseCLIArgumentz�<p>The file that contains the private key used to launch
the instance (e.g. windows-keypair.pem).  If this is supplied, the
password data sent from EC2 will be decrypted before display.</p>cKst||d�|d<dS)z�
    This handler gets called after the argument table for the
    operation has been created.  It's job is to add the
    ``priv-launch-key`` parameter.
    zpriv-launch-keyN)�LaunchKeyArgument)Zargument_table�operation_model�session�kwargs�r	�%/usr/lib/python3.6/decryptpassword.py�ec2_add_priv_launch_key src@s^eZdZdd�Zedd��Zedd��Zejdd��Zedd	��Zd
d�Z	dd
�Z
dd�ZdS)rcCs4||_tjdddi�|_||_||_d|_d|_dS)Nr�type�stringF)�_sessionrZShapeZargument_model�_operation_model�_name�	_key_path�	_required)�selfrr�namer	r	r
�__init__-szLaunchKeyArgument.__init__cCsdS)Nr
r	)rr	r	r
�
cli_type_name5szLaunchKeyArgument.cli_type_namecCs|jS)N)r)rr	r	r
�required9szLaunchKeyArgument.requiredcCs
||_dS)N)r)r�valuer	r	r
r=scCstS)N)�HELP)rr	r	r
�
documentationAszLaunchKeyArgument.documentationcCs|j|j|jdd�dS)NzSSH Private Key file)�dest�help)�add_argumentZcli_nameZpy_name)r�parserr	r	r
�
add_to_parserEszLaunchKeyArgument.add_to_parsercCsj|rftjj|�}tjj|�}tjj|�rZ||_|jjj}d||jj	f}|j
j||j�nd}t
|��dS)a
        This gets called with the value of our ``--priv-launch-key``
        if it is specified.  It needs to determine if the path
        provided is valid and, if it is, it stores it in the instance
        variable ``_key_path`` for use by the decrypt routine.
        zafter-call.%s.%sz_priv-launch-key should be a path to the local SSH private key file used to launch the instance.N)�os�path�
expandvars�
expanduser�isfilerrZ
service_model�endpoint_prefixrr�register�_decrypt_password_data�
ValueError)rZ
parametersrr!r%Zevent�msgr	r	r
�
add_to_paramsIs
zLaunchKeyArgument.add_to_paramscKs�|jdk	r�tjd|j�|jd�}|s*dSylt|j��X}|j�}tjjt	j
|��}tj|�}tj
||�}tj|�|jd�|d<tj|�WdQRXWn.tk
r�tjddd�d}t|��YnXdS)	aq
        This handler gets called after the GetPasswordData command has been
        executed.  It is called with the and the ``parsed`` data.  It checks to
        see if a private launch key was specified on the command.  If it was,
        it tries to use that private key to decrypt the password data and
        replace it in the returned data dictionary.
        Nz"Decrypting password data using: %sZPasswordDatazutf-8zUnable to decrypt PasswordDataT)�exc_infoz@Unable to decrypt password data using provided private key file.)r�logger�debug�get�open�read�rsaZ
PrivateKeyZ
load_pkcs1r�b�base64Z	b64decodeZdecrypt�decode�	Exceptionr()rZparsedrrZpk_fileZpk_contentsZprivate_keyr)r	r	r
r'`s$



z(LaunchKeyArgument._decrypt_password_dataN)�__name__�
__module__�__qualname__r�propertyrr�setterrrr*r'r	r	r	r
r+sr)Zloggingr r3r1Z
awscli.compatrZbotocorerZawscli.argumentsrZ	getLoggerr6r,rrrr	r	r	r
�<module>
s