← Back
Editing: __init__.cpython-38.pyc
U t5Y^�/ � @ s� d dl Z d dlZd dlZzd dlmZ W n ek r@ eZY nX d dlZd dlZd dl Z d dl Z d dlZd dlZd dl Z d dlZzd dlmZ W n ek r� d dlmZ Y nX ddlmZ dZejdejd� e jd d d�Zejdd ddd� ejdddddd� ejdddddd� ejdddd d!� de_g Zd"d#� Zd$d%� Zd&d'� ZdEd)d*�Zd+d,� Z d-d.� Z!d/d0� Z"dFd1d2�Z#d3d4� Z$d5d6� Z%d7d8� Z&d9d:� Z'd;d<� Z(dGd=d>�Z)d?d@� Z*dAdB� Z+dCdD� Z,dS )H� N)�JSONDecodeError)� quote_plus� )�VERSION�lpz%%(asctime)s %(levelname)s %(message)s)�format�levelz9Authorize SSH public keys from trusted online identities.z ssh-import-id)Zdescription�progz-oz--outputZFILEz5Write output to file (default ~/.ssh/authorized_keys))�metavar�helpz-rz--remove� store_trueFz&Remove a key from authorized keys file)�action�defaultr z-uz--useragentZ USERAGENT� z$Append to the http user agent string)r r r �userids�+ZUSERIDzUser IDs to import)�nargsr r c C s$ t D ]} tj�| �rt�| � qdS )z Cleanup tempfiles N)� TEMPFILES�os�path�exists�unlink)�f� r �8/usr/lib/python3/dist-packages/ssh_import_id/__init__.py�cleanupD s r c C s t �| � t� t�d� dS )z. The only thing in Perl worth keeping r N)�logging�errorr �sys�exit)�msgr r r �dieM s r! c C s� | sdS t | �dk rdS tjddd�\}}t�|� t�|d�� }|�d�| �� |�d� W 5 Q R X t j d d d|gt jd�}|�d�\}}|j r�dS t�|� |�� }|r�t |�d k r�dS g }|�� D ]} |�t| �d��� �� q�|S )z^ Get the fingerprint for an SSH public key Returns None if not valid key material N� zssh-auth-key-checkz.pub)�prefix�suffix�w� � z ssh-keygenz-lz-f)�stdout� zutf-8)�len�tempfileZmkstempr �appendr �fdopen�write�join� subprocess�Popen�PIPEZcommunicate� returncoder �split�str�decode�strip) �fieldsZtempfdZtempnameZtempfZkeygen_procZ keygen_out�_Z keygen_fields�out�kr r r �key_fingerprintV s6 � � r<