HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/thread-self/root/lib/python3/dist-packages/apt/__pycache__/auth.cpython-38.pyc
U

&��c�*�@s�dZddlmZzddlmZWnek
r4YnXddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddl
mZejjdkr�eZz$ddlmZmZmZeeeWnek
r�YnXGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$d d!�Z%e&d"k�r�d#d$�d%d$�e
�'�e%�D]Z(e)e(��qtdS)&z4Handle GnuPG keys used to trust signed repositories.�)�print_function)�OptionalN)�gettext�)�List�Tuple�Unionc@seZdZdS)�AptKeyErrorN)�__name__�
__module__�__qualname__�r
r
�*/usr/lib/python3/dist-packages/apt/auth.pyr	:sr	c@seZdZdZdS)�AptKeyIDTooShortErrorz!Internal class do not rely on it.N)r
rr�__doc__r
r
r
rr>src@s eZdZdZdd�Zdd�ZdS)�
TrustedKeyzRepresents a trusted key.cCs ||_t|�|_||_||_dS)N)Zraw_name�_�name�keyid�date)�selfrrrr
r
r�__init__Fs
zTrustedKey.__init__cCsd|j|j|jfS)Nz%s
%s %s)rrr)rr
r
r�__str__NszTrustedKey.__str__N)r
rrrrrr
r
r
rrBsrc	Os0d}tj�dd�g}|�|�tj��}d|d<d|d<z�tj�d�d	kr�t	j
d
dd�}|�tj���
d
��|��|j|d<tj||dtjtjtjd�}|�dd�}tjjdkr�t|t�r�|�
d�}|�|�\}}|jr�td|jd�|�||f��n|�rtj�|�|��W�S|dk	�r*|��XdS)z0Run the apt-key script with the given arguments.NzDir::Bin::Apt-Keyz/usr/bin/apt-key�CZLANG�1Z$APT_KEY_DONT_WARN_ON_DANGEROUS_USAGEZDir�/zapt-keyz.conf)�prefix�suffixzUTF-8Z
APT_CONFIGT)�env�universal_newlines�stdin�stdout�stderrr �zutf-8zGThe apt-key script failed with return code %s:
%s
stdout: %s
stderr: %s� )�apt_pkgZconfigZ	find_file�extend�os�environ�copy�closeZfind_dir�tempfileZNamedTemporaryFile�write�dump�encode�flushr�
subprocess�Popen�PIPE�get�sys�version_info�major�
isinstance�unicode�communicate�
returncoder	�joinr"�strip)	�args�kwargsZconf�cmdr�procr �outputr"r
r
r�_call_apt_key_scriptSsN

�

�
���
rBcCs@tj�|�std|��t�|tj�s2td|��td|�dS)z�Import a GnuPG key file to trust repositores signed by it.

    Keyword arguments:
    filename -- the absolute path to the public GnuPG key file
    z An absolute path is required: %szKey file cannot be accessed: %s�addN)r'�path�abspathr	�access�R_OKrB)�filenamer
r
r�add_key_from_file�s
rIc
CsRt��}z,zt|||�Wntk
r0�YnXW5dd�}tj||d�XdS)z�Import a GnuPG key file to trust repositores signed by it.

    Keyword arguments:
    keyid -- the long keyid (fingerprint) of the key, e.g.
             A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553
    keyserver -- the URL or hostname of the key server
    cSs(t|dt�r"|djtjkr"dS�dS)N�)r7�OSError�errnoZENOENT)�funcrD�exc_infor
r
r�onerror�s
�z'add_key_from_keyserver.<locals>.onerror)rON)r+Zmkdtemp�shutilZrmtree�_add_key_from_keyserver�	Exception)r�	keyserver�tmp_keyring_dirrOr
r
r�add_key_from_keyserver�s	rUcCsNt|�dd��dd��dkr$td��tj�|d�}tj�|d�}dd	d
d|g}t�|d|d
|d|d|g�}|dkr�td||f��tj�|d�}t�|d
|d|d|g�}|dkr�td|��tj	|d
|ddddgtj
dd���d}d}	|��D]"}
|
�
d�r�|
�d�d}	�qq�|�dd���}|	|k�rBtd||f��t|�dS)Nr$�Z0xgD@z,Only fingerprints (v4, 160bit) are supportedzsecring.gpgzpubring.gpgZgpgz--no-default-keyringz--no-optionsz	--homedirz--secret-keyringz	--keyringz--keyserverz--recvrzrecv from '%s' failed for '%s'zexport-keyring.gpgz--outputz--exportzexport of '%s' failedz
--fingerprint�--batch�--fixed-list-mode�
--with-colonsT)r!rzfpr:�:�	)�len�replacerr'rDr;r0Zcallr	r1r2r9�
splitlines�
startswith�split�upperrI)rrSrTZtmp_secret_keyringZtmp_keyringZgpg_default_options�resZtmp_export_keyringrAZgot_fingerprint�lineZsigning_key_fingerprintr
r
rrQ�s�����
�
��	�


��rQcCstddddd|d�dS)z�Import a GnuPG key to trust repositores signed by it.

    Keyword arguments:
    content -- the content of the GnuPG public key
    �advz--quietrWz--import�-)r N�rB)Zcontentr
r
r�add_key�s
�rgcCstd|�dS)z�Remove a GnuPG key to no longer trust repositores signed by it.

    Keyword arguments:
    fingerprint -- the fingerprint identifying the key
    ZrmNrf�Zfingerprintr
r
r�
remove_key�sricCs
td|�S)zxReturn the GnuPG key in text format.

    Keyword arguments:
    fingerprint -- the fingerprint identifying the key
    Zexportrfrhr
r
r�
export_key	srjcCstd�S)aUpdate the local keyring with the archive keyring and remove from
    the local keyring the archive keys which are no longer valid. The
    archive keyring is shipped in the archive-keyring package of your
    distribution, e.g. the debian-archive-keyring package in Debian.
    �updaterfr
r
r
rrksrkcCstd�S)ayWork similar to the update command above, but get the archive
    keyring from an URI instead and validate it against a master key.
    This requires an installed wget(1) and an APT build configured to
    have a server to fetch from and a master keyring to validate. APT
    in Debian does not support this command and relies on update
    instead, but Ubuntu's APT does.
    z
net-updaterfr
r
r
r�
net_updates	rlcCsxtddddd�}g}|�d�D]T}|�d�}|dd	kr@|d
}|ddkr|d}|d
}t|||�}|�|�q|S)zaReturns a list of TrustedKey instances for each key which is
    used to trust repositories.
    rdrYrWrXz--list-keys�
rZrZpub��uidr[�)rBr`r�append)rArbrcZfieldsrroZ
creation_date�keyr
r
r�	list_keys)s�
rs�__main__cCstd�S)Nz;Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>�rr
r
r
r�<lambda>B�rvcCstd�S)Nz:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>rur
r
r
rrvCrw)*rZ
__future__r�typingr�ImportErrorrLr'�os.pathrPr0r4r+r%rrr5r6�strr8rrrrRr	r�objectrrBrIrUrQrgrirjrkrlrsr
ZinitZtrusted_key�printr
r
r
r�<module>sT0H