File: //usr/lib/python3.9/site-packages/ansible/galaxy/collection/__pycache__/gpg.cpython-39.pyc
a
�)g� � @ sX d Z ddlmZ ddlmZ ddlmZ ddlZddlZddl Z ddl
Z
ddlZddl
mZmZ ddlmZ ddlmZmZ ejr�dd lmZ e
jdd
� dkZeefdd
ier�dd
ini ��Zd8dd�Zdd� Zdd� ZeG dd� de��Z eG dd� de ��Z!eG dd� de ��Z"eG dd� de ��Z#eG dd� de ��Z$eG dd � d e ��Z%eG d!d"� d"e ��Z&eG d#d$� d$e ��Z'eG d%d&� d&e ��Z(eG d'd(� d(e ��Z)eG d)d*� d*e ��Z*eG d+d,� d,e ��Z+eG d-d.� d.e ��Z,eG d/d0� d0e ��Z-eG d1d2� d2e ��Z.eG d3d4� d4e ��Z/eG d5d6� d6e ��Z0e!e"e#e$e%e&e'e(e)e*e+e,e-e.e/e0d7�Z1dS )9zSignature verification helpers.� )�AnsibleError)�
user_agent)�open_urlN)� dataclass�fields)�partial)� HTTPError�URLError)�Display� )� �
�frozenT�slotsc
C s� |d ur|� d| � �� z>t| t� ddd��}|�� }W d � n1 sJ0 Y W n> ttfy� } z"td| � d|� ��|�W Y d }~n
d }~0 0 |S )NzUsing signature at T�safe)Z
http_agentZvalidate_certsZfollow_redirectsz:Failed to get signature for collection verification from '�': )�vvvvr r �readr r r )�source�displayZresp� signature�e� r �A/usr/lib/python3.9/site-packages/ansible/galaxy/collection/gpg.py�get_signature_from_source s$ �*��r c
C s� t �� \}}t j�|� }dd|� �ddddd|� �d| g }d �|�}|�d
|� d�� z�z"tj|tjtjtj|fdd
�} W n@ t tj
fy� }
z"td|� d|
� ��|
�W Y d }
~
nd }
~
0 0 | j|d�\}}W t �
|� nt �
|� 0 |�r$t�t�� t �|� W d � n1 �s0 Y t �|��B}
|
�� }|�d|� d|� d| j� d�� || jfW d � S 1 �sx0 Y d S )NZgpgz--status-fd=z--verifyz--batchz--no-ttyz--no-default-keyringz
--keyring=�-� zRunning command '�'�utf8)�stdin�stdout�stderrZpass_fds�encodingz/Failed during GnuPG verification with command 'r )�inputz stdout:
z
stderr:
z
(exit code �))�os�pipe�path�exists�joinr �
subprocess�Popen�PIPE�FileNotFoundErrorZSubprocessErrorr Zcommunicate�close�
contextlib�suppress�OSError�remove�fdopenr �
returncode)Z
manifest_filer Zkeyringr Zstatus_fd_readZstatus_fd_writeZ
remove_keybox�cmdZcmd_str�p�errr r! �fr r r �run_gpg_verify/ sP �
�
��*�r9 c c s� | � � D ]�}|sqz|jdd�\}}}W n& tyN |jdd�\}}d }Y n0 zt| }W n tyr Y qY n0 |g}|r�|�|�d tt|��d �� ||� V qd S )Nr )�maxsplit� )�
splitlines�split�
ValueError�
GPG_ERROR_MAP�KeyError�extend�len� dc_fields)Z
status_out�lineZ_dummy�statusZ remainder�clsr r r r �parse_gpg_errorsf s*
��rG c s8 e Zd ZU eed<