|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/__pycache__/ |
U
N��gTG � @ s$ d Z ddlZddlmZ ddlmZ ddlmZ ddlZddlZddl Z ddl
Z
ddlmZm
Z
ddlZddlZdZdZd ZdZejd
kr�zddlmZmZmZ W n ek
r� dZY nX ze dZeZeZeefZW n& e k
r� d
ZeZeZefZY nX e�!e"�Z#e#j$�s e#�%e�&� � dZ'ej(j"dk�r<dd� Z)ne �*d�Z+dd� Z)e�,� Z-dd� Z.dd� Z/dd� Z0dd� Z1dd� Z2dd� Z3dd � Z4G d!d"� d"e5�Z6G d#d$� d$e6�Z7G d%d&� d&e6�Z8e �*d'e j9�Z:d(d)d*d+d,d-d.�Z;G d/d0� d0e6�Z<d1d2� Z=G d3d4� d4e6e>�Z?G d5d6� d6e?�Z@G d7d8� d8e@�ZAG d9d:� d:e5�ZBd;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJ�ZCdKdL� ZDG dMdN� dNe7eB�ZEG dOdP� dPe6�ZFG dQdR� dRe6�ZGG dSdT� dTeF�ZHG dUdV� dVe6�ZIG dWdX� dXeI�ZJG dYdZ� dZe6eB�ZKG d[d\� d\e6�ZLe �*d]�Md^��ZNe �*d_e j9�ZOe �*d`�ZPG dadb� dbe5�ZQdS )ca� A wrapper for the GnuPG `gpg` command.
Portions of this module are derived from A.M. Kuchling's well-designed
GPG.py, using Richard Jones' updated version 1.3, which can be found
in the pycrypto CVS repository on Sourceforge:
http://pycrypto.cvs.sourceforge.net/viewvc/pycrypto/gpg/GPG.py
This module is *not* forward-compatible with amk's; some of the
old interface has changed. For instance, since I've added decrypt
functionality, I elected to initialize with a 'gnupghome' argument
instead of 'keyring', so that gpg can find both the public and secret
keyrings. I've also altered some of the returned objects in order for
the caller to not have to know as much about the internals of the
result classes.
While the rest of ISconf is released under the GPL, I am releasing
this single file under the same terms that A.M. Kuchling used for
pycrypto.
Steve Traugott, stevegt@terraluna.org
Thu Jun 23 21:27:20 PDT 2005
This version of the module has been modified from Steve Traugott's version
(see http://trac.t7a.org/isconf/browser/trunk/lib/python/isconf/GPG.py) by
Vinay Sajip to make use of the subprocess module (Steve's version uses os.fork()
and so does not work on Windows). Renamed to gnupg.py to avoid confusion with
the previous versions.
Modifications Copyright (C) 2008-2024 Vinay Sajip. All rights reserved.
For the full documentation, see https://docs.red-dove.com/python-gnupg/ or
https://gnupg.readthedocs.io/
� N)�datetime)� parseaddr)�StringIO)�Popen�PIPEz0.5.4zVinay Sajipz$07-Jan-2025 10:13:17$�nt)�STARTUPINFO�STARTF_USESHOWWINDOW�SW_HIDEFT�ntpathc C s d| S )Nz"%s"� ��sr r �2/opt/cppython/lib/python3.8/site-packages/gnupg.py�shell_quoteV s r z[^\w%+,./:=@-]c C sH t | t�stdt| � ��| s$d}n t�| �s4| }nd| �dd� }|S )au
Quote text so that it is safe for POSIX command shells.
For example, "*.py" would be converted to "'*.py'". If the text is considered safe it is returned unquoted.
Args:
s (str): The value to quote
Returns:
str: A safe version of the input, from the point of view of POSIX
command shells.
zExpected string type, got %sz''z'%s'�'z'\'')�
isinstance�string_types� TypeError�type�UNSAFE�search�replace)r �resultr r r r _ s
c C s t st| t�r| �t�} | S )z7
Legacy function which is a no-op on Python 3.
)�_py3kr � text_type�encode�
fsencodingr
r r r �no_quote� s
r c C s |dkst �d}ttjd�r&tjj}nd}z| �|�}W n& tk
r^ tjddd� Y q�Y nX |sfq�|t |�7 }z|�
|� W q* tk
r� |�
|�|�� Y q* tk
r� t�
d� Y q�Y q*X q*z|�� W n" tk
r� tjddd� Y nX t�d |� d S )
Nr �encoding�asciiz Exception occurred while reading� )�exc_infozError sending dataz)Exception occurred while closing: ignoredzclosed output, %d bytes sent)�AssertionError�hasattr�sys�stdinr �read� Exception�logger�warning�len�write�UnicodeErrorr � exception�close�IOError�debug)�instream� outstream�buffer_size�sent�enc�datar r r �
_copy_data� s2
r8 c C sB |dkst �tjt| ||fd�}d|_t�d|| |� |�� |S )Nr ��target�argsTzdata copier: %r, %r, %r)r# � threading�Threadr8 �daemonr) r1 �start)r2 r3 r4 �wrr r r �_threaded_copy_data� s rA c C s* d| }|� |�}| �|� t�d� d S )Nz%s
zWrote passphrase)r r, r) r1 )�stream�
passphraser r r r �_write_passphrase� s
rD c C s t | ttttf�S �N)r �list�tuple�set� frozenset)�instancer r r �_is_sequence� s rK c C s: zddl m} || �}W n tk
r4 t| �}Y nX |S )Nr )�BytesIO)�iorL �ImportErrorr )r rL �rvr r r �_make_memory_stream� s rP c C s8 t rt| t�r0| �|�} nt| �tk r0| �|�} t| �S rE )r r �strr r rP )r r r r r �_make_binary_stream� s
rR c @ s$ e Zd ZdZdZdd� Zdd� ZdS )�
StatusHandlerzA
The base class for handling status messages from `gpg`.
Nc C s
|| _ dS )zq
Initialize an instance.
Args:
gpg (GPG): The :class:`GPG` instance in use.
N)�gpg��selfrT r r r �__init__� s zStatusHandler.__init__c C s t �dS )a.
Handle status messages from the `gpg` child process. These are lines of the format
[GNUPG:] <key> <value>
Args:
key (str): Identifies what the status message is.
value (str): Identifies additional data, which differs depending on the key.
N)�NotImplementedError�rV �key�valuer r r �
handle_status� s
zStatusHandler.handle_status)�__name__�
__module__�__qualname__�__doc__�on_data_failurerW r\ r r r r rS � s rS c @ sp e Zd ZdZdZdZdZdZdZdZ eeeeee d�Z
d d
ddd
�ZddiZdZ
dd� Zdd� ZeZdd� ZdS )�VerifyzJ
This class handles status messages during signature verificaton.
r r! � � � � )�
TRUST_EXPIRED�TRUST_UNDEFINED�TRUST_NEVER�TRUST_MARGINAL�TRUST_FULLY�TRUST_ULTIMATEzpermission deniedzfile existszfile not foundznot a directory)r! �# �Q �a � zincorrect passphraseNc C sv t �| |� d| _d | _ | _| _d | _| _d | _d | _d | _ d | _
d | _d | _d | _
d | _d | _i | _g | _d S �NF)rS rW �valid�fingerprint�
creation_date� timestamp�signature_id�key_id�username�
key_status�status�pubkey_fingerprint�expire_timestamp�
sig_timestamp�
trust_text�trust_level�sig_info�problemsrU r r r rW s zVerify.__init__c C s | j S rE )rr �rV r r r �__nonzero__) s zVerify.__nonzero__c s� � fdd�}|� j krB|� _� j | � _|� j� jd� d � _�n@|dkr\t�d||� �n&|dkr�d� _d� _|�d d �\� _ � _
� j�� j� j � j
d
�� |� j � j
� jd� �n�|dk�r>d� _|�� }|d d
� \� _ }}}� _
t|�dkr�|d � _d� _|� j � j
� j� jd� � j�� j� j � j
� jd�� �nD|dk�r�d� _d� _|�d d �\� _ � _
|� j � j
� jd� � j�� j� j � j
d
�� �n�|dk�r�d� _d� _|�d d �\� _ � _
|� j � j
� jd� �n�|dk�rX|�� }|d d� \}} }
}|| |
|f\� _� _� _� _t|�dk�r6|d � _d� _||| |
|� j� jd� �n*|dk�r�|�� \}} }
| |
d�� j|<