HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/ec2/__pycache__/decryptpassword.cpython-310.pyc
o

.&�a��@snddlZddlZddlZddlZddlmZddlmZddlm	Z	e�
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)�argument_table�operation_model�session�kwargs�r
�K/usr/lib/python3/dist-packages/awscli/customizations/ec2/decryptpassword.py�ec2_add_priv_launch_key s�rc@s^eZdZdd�Zedd��Zedd��Zejdd��Zedd	��Zd
d�Z	dd
�Z
dd�ZdS)rcCs4||_t�dddi�|_||_||_d|_d|_dS)Nr�type�stringF)�_sessionr�Shape�argument_model�_operation_model�_name�	_key_path�	_required)�selfrr�namer
r
r�__init__-s
zLaunchKeyArgument.__init__cCsdS)Nrr
�rr
r
r�
cli_type_name5�zLaunchKeyArgument.cli_type_namecCs|jS�N�rrr
r
r�required9szLaunchKeyArgument.requiredcCs
||_dSrr)r�valuer
r
rr=s
cCstSr)�HELPrr
r
r�
documentationArzLaunchKeyArgument.documentationcCs|j|j|jdd�dS)NzSSH Private Key file)�dest�help)�add_argument�cli_name�py_name)r�parserr
r
r�
add_to_parserEs
�zLaunchKeyArgument.add_to_parsercCsl|r4tj�|�}tj�|�}tj�|�r.||_|jjj}d||jj	f}|j
�||j�dSd}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�isfilerr�
service_model�endpoint_prefixrr�register�_decrypt_password_data�
ValueError)r�
parametersrr*r/�event�msgr
r
r�
add_to_paramsIs���zLaunchKeyArgument.add_to_paramscKs�|jdurmt�d|j�|�d�}|sdSzCt|j��3}|��}tj�t	�
|��}t�|�}t�
||�}t�|�|�d�|d<t�|�Wd�WdS1sQwYWdStyltjddd�d}t|��wdS)	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: %s�PasswordDatazutf-8zUnable to decrypt PasswordDataT)�exc_infoz@Unable to decrypt password data using provided private key file.)r�logger�debug�get�open�read�rsa�
PrivateKey�
load_pkcs1r�b�base64�	b64decode�decrypt�decode�	Exceptionr2)r�parsedr	r�pk_file�pk_contents�private_keyr5r
r
rr1`s*



&���z(LaunchKeyArgument._decrypt_password_dataN)�__name__�
__module__�__qualname__r�propertyrr�setterr!r(r6r1r
r
r
rr+s



r)�loggingr)rBr>�
awscli.compatr�botocorer�awscli.argumentsr�	getLoggerrKr9r rrr
r
r
r�<module>s