File: //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/__pycache__/gnupg.cpython-310.pyc
o
;jM � @ sT d Z ddlZddlmZ ddlmZ ddlmZ ddlZddlZz
ddl m
Z
mZ W n ey; ddl
m
Z
mZ Y nw ddl
Z
ddlZddlmZmZ ddlZddlZdZd Zd
ZdZejdkryzddlmZmZmZ W n eyx dZY nw ze d
ZeZeZe e!fZ"W n e#y� dZe!Ze!Ze!fZ"Y nw e�$e%�Z&e&j's�e&�(e�)� � d
Z*ej+j%dkr�dd� Z,n e
�-d�Z.dd� Z,e�/� Z0dd� Z1dd� Z2dd� Z3dd� Z4dd� Z5dd� Z6d d!� Z7G d"d#� d#e8�Z9G d$d%� d%e9�Z:G d&d'� d'e9�Z;e
�-d(e
j<�Z=d)d*d+d,d-d.d/�Z>G d0d1� d1e9�Z?d2d3� Z@G d4d5� d5e9eA�ZBG d6d7� d7eB�ZCG d8d9� d9eC�ZDG d:d;� d;e8�ZEd<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdK�ZFdLdM� ZGG dNdO� dOe:eE�ZHG dPdQ� dQe9�ZIG dRdS� dSe9�ZJG dTdU� dUeI�ZKG dVdW� dWe9�ZLG dXdY� dYeL�ZMG dZd[� d[e9eE�ZNG d\d]� d]e9�ZOe
�-d^�Pd_��ZQe
�-d`e
j<�ZRe
�-da�ZSG dbdc� dce8�ZTdS )da� 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-2025 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)�Queue�Empty)�Popen�PIPEz0.5.6zVinay Sajipz$31-Dec-2025 16:41:34$�nt)�STARTUPINFO�STARTF_USESHOWWINDOW�SW_HIDEFT�ntpathc C s d| S )Nz"%s"� ��sr r �9/opt/saltstack/salt/lib/python3.10/site-packages/gnupg.py�shell_quoteZ s r z[^\w%+,./:=@-]c C sL t | t�s
tdt| � ��| sd}|S t�| �s| }|S d| �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 c 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 s2 |dksJ �d}t tjd�rtjj}nd} z| �|�}W n ty; } ztjddd� |�|� W Y d }~nCd }~ww |s?n;|t |�7 }z|�
|� W n, ty] |�
|�|�� Y n tyx } zt�
d� |�|� W Y d }~nd }~ww qz|�� W n ty� tjd dd� Y nw t�d
|� d S )Nr �encoding�asciiTz Exception occurred while reading� )�exc_infozError sending dataz)Exception occurred while closing: ignoredzclosed output, %d bytes sent)�hasattr�sys�stdinr! �read� Exception�logger�warning�
put_nowait�len�write�UnicodeErrorr � exception�close�IOError�debug)�instream� outstream�buffer_size�error_queue�sent�enc�data�er r r �
_copy_data� sD
��
����r<