CasperSecurity

Current Path : /lib/python3/dist-packages/apt/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/apt/__pycache__/auth.cpython-310.pyc

o

4��fg)�@s,dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddl
mZddl
mZmZmZGdd�de�ZGdd	�d	e�ZGd
d�de�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Ze d kr�d!d"�d#d"�e
�!�e�D]Z"e#e"�q�dSdS)$z4Handle GnuPG keys used to trust signed repositories.�)�print_functionN)�gettext)�List�Optional�Tuplec@seZdZdS)�AptKeyErrorN)�__name__�
__module__�__qualname__�rr�*/usr/lib/python3/dist-packages/apt/auth.pyr+src@seZdZdZdS)�AptKeyIDTooShortErrorz!Internal class do not rely on it.N)rr	r
�__doc__rrrrr
/sr
c@s eZdZdZdd�Zdd�ZdS)�
TrustedKeyzRepresents a trusted key.cCs ||_t|�|_||_||_dS)N)�raw_name�_�name�keyid�date)�selfrrrrrr�__init__7s

zTrustedKey.__init__cCsd|j|j|jfS)Nz%s
%s %s)rrr)rrrr�__str__?szTrustedKey.__str__N)rr	r
rrrrrrrr3src	Osd}tj�dd�g}|�|�tj��}d|d<d|d<zetj�d�d	kr@tj	d
dd�}|�
tj���d
��|�
�|j|d<tj||dtjtjtjd�}|�dd�}|�|�\}}|jrltd|jd�|�||f��|rttj�
|�|��W|dur�|��SS|dur�|��ww)z0Run the apt-key script with the given arguments.NzDir::Bin::Apt-Keyz/usr/bin/apt-key�C�LANG�1�$APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE�Dir�/zapt-keyz.conf)�prefix�suffixzUTF-8�
APT_CONFIGT)�env�universal_newlines�stdin�stdout�stderrr#zGThe apt-key script failed with return code %s:
%s
stdout: %s
stderr: %s� )�apt_pkg�config�	find_file�extend�os�environ�copy�find_dir�tempfile�NamedTemporaryFile�write�dump�encode�flushr�
subprocess�Popen�PIPE�get�communicate�
returncoder�join�sysr%�strip�close)	�args�kwargs�conf�cmdr!�procr#�outputr%rrr�_call_apt_key_scriptDsH

�

����

�
�rEcCs@tj�|�std|��t�|tj�std|��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_OKrE)�filenamerrr�add_key_from_fileqs
rLc
Cs`t��}zzt|||�Wnty�wWdd�}tj||d�dSdd�}tj||d�w)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|djtjkrdS�)N�)�
isinstance�OSError�errno�ENOENT)�funcrG�exc_inforrr�onerror�sz'add_key_from_keyserver.<locals>.onerror)rTN)r/�mkdtemp�_add_key_from_keyserver�	Exception�shutil�rmtree)r�	keyserver�tmp_keyring_dirrTrrr�add_key_from_keyservers	���r\cCsJt|�dd��dd��dkrtd��tj�|d�}tj�|d�}dd	d
d|g}t�|d|d
|d|d|g�}|dkrBtd||f��tj�|d�}t�|d
|d|d|g�}|dkr_td|��tj	|d
|ddddgtj
dd���d}d}	|��D]}
|
�
d�r�|
�d�d}	nqz|�dd���}|	|kr�td||f��t|�dS)Nr&��0xgD@z,Only fingerprints (v4, 160bit) are supportedzsecring.gpgzpubring.gpg�gpgz--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$r"zfpr:�:�	)�len�replacer
r+rGr;r5�callrr6r7r9�
splitlines�
startswith�split�upperrL)rrZr[�tmp_secret_keyring�tmp_keyring�gpg_default_options�res�tmp_export_keyringrD�got_fingerprint�line�signing_key_fingerprintrrrrV�sn����
�
��	�

���rVcCstddddd|d�dS)z�Import a GnuPG key to trust repositores signed by it.

    Keyword arguments:
    content -- the content of the GnuPG public key
    �advz--quietr`z--import�-)r#N�rE)�contentrrr�add_key�s
�rxcCstd|�dS)z�Remove a GnuPG key to no longer trust repositores signed by it.

    Keyword arguments:
    fingerprint -- the fingerprint identifying the key
    �rmNrv��fingerprintrrr�
remove_key�sr|cCs
td|�S)zxReturn the GnuPG key in text format.

    Keyword arguments:
    fingerprint -- the fingerprint identifying the key
    �exportrvrzrrr�
export_key�s
r~cC�td�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.
    �updatervrrrrr�sr�cCr)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-updatervrrrr�
net_updates	r�cCsxtddddd�}g}|�d�D]*}|�d�}|dd	kr |d
}|ddkr9|d}|d
}t|||�}|�|�q|S)zaReturns a list of TrustedKey instances for each key which is
    used to trust repositories.
    rtrbr`raz--list-keys�
rcr�pub��uidrd�)rErjr�append)rDrorr�fieldsrr��
creation_date�keyrrr�	list_keyss�

�r��__main__cCr)Nz;Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>�rrrrr�<lambda>0�r�cCr)Nz:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>r�rrrrr�1r�)$r�
__future__rrPr+�os.pathrXr5r<r/r'rr�typingrrrrWrr
�objectrrErLr\rVrxr|r~r�r�r�r�init�trusted_key�printrrrr�<module>sB-H




�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY