https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/duplicity/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/duplicity/__pycache__/gpg.cpython-310.pyc
o

��`.E�@s4dZddlmZddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZdd	lmZzdd
lmZddlmZWneygddlmZddlmZYnwd
ZGdd�de�ZGdd�de�ZGdd�de�Z		d!dd�Zd"dd�Zd#dd�Zd$dd �ZdS)%z�
duplicity's gpg interface, builds upon Frank Tobin's GnuPGInterface
which is now patched with some code for iterative threaded execution
see duplicity's README for details
�)�next)�str)�objectN)�config)�gpginterface)�tempdir)�util)�sha1)�md5)�newic@seZdZdZdS)�GPGErrorz!
    Indicate some GPG Error
    N)�__name__�
__module__�__qualname__�__doc__�rr�//usr/lib/python3/dist-packages/duplicity/gpg.pyr5src@s4eZdZdZ		ddd�ZejZed�Zdd�Z	dS)	�
GPGProfilezF
    Just hold some GPG settings, avoid passing tons of arguments
    NcCs�|dust|tdjf�sJ�||_||_||_d|_|dur)t|t�s%J�||_ng|_|dur;t|t�s7J�||_	ng|_	|�
tj�|_
dS)a>
        Set all data with initializer

        passphrase is the passphrase.  If it is None (not ""), assume
        it hasn't been set.  sign_key can be blank if no signing is
        indicated, and recipients should be a list of keys.  For all
        keys, the format should be an hex key like 'AA0E73D2'.
        N�)�
isinstancer�	__class__�
passphrase�signing_passphrase�sign_key�encrypt_secring�list�
recipients�hidden_recipients�get_gpg_versionr�
gpg_binary�gpg_version)�selfrrrrrrr�__init__@s
zGPGProfile.__init__sU^gpg.*\(GnuPG(?:/MacGPG2)?\) (?P<maj>[0-9]+)\.(?P<min>[0-9]+)\.(?P<bug>[0-9]+)(-.+)?$cCs�t��}|dur||_tjrtj��D]	}|jj�|�q|j	dgdgd�}|j
d����}|j
�|�}|durMt|�d��t|�d��t|�d��fStd||f��)Nz	--version�stdout)�
create_fhs�maj�min�bugz/failed to determine gnupg version of %s from %s)r�GnuPG�callr�gpg_options�split�options�
extra_args�append�run�handles�readline�rstrip�_version_re�search�int�groupr)r!�binary�gnupg�opt�res�line�mrrrras(zGPGProfile.get_gpg_version)NNNN)
r
rrrr"�re�compile�rcr3rrrrrr<s
�rc@sZeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�GPGFilezI
    File-like object that encrypts decrypts another file on the fly
    c
Cs�d|_d|_tjt����d�|_tjt����d�|_||_	d|_
t��}t
jdur/t
j|_d|j_|jj�d�|jj�d�|jdd�dkrUt
jrT|jj�d�n%|jdd	�d
kr_n|jdd	�dkrst
jsr|jj�d�ntd
|j��t
jr�t
j��D]	}|jj�|�q�g}|jr�|j|j_|�d�|r�|jr�|jr�|j}n|j}|dur�d}|�r|jr�|j|j_|�d�|jr�|j|j_|�d�|js�|js�|�d�|jj�d�t
jr�dg}nddg}|j|||� d�|j|jd�d�}	t
j�s|	j!d�"|�|	j!d�#�|	j!d|_$n[|j�s|j�r,|j%�r,|�d�|�|j%�tjt����d�|_t
j�r?dg}nddg}|jdg||� d�|j|j|jd�d�}	t
j�sj|	j!d�"|�|	j!d�#�|	j!d|_&|	|_'||_(dS)a�
        GPGFile initializer

        If recipients is set, use public key encryption and encrypt to
        the given keys.  Otherwise, use symmetric encryption.

        encrypt_path is the Path of the gpg encrypted file.  Right now
        only symmetric encryption/decryption is supported.

        If passphrase is false, do not set passphrase - GPG program
        should prompt for it.
        N)�dirrz--no-secmem-warningz--ignore-mdc-error��rBz--use-agent�)rDr)rDrBz--pinentry-mode=loopbackzUnsupported GNUPG version, %sz--signrz	--encryptz--symmetricz--force-mdc�stdinr�wb)r#�stderr�logger)r$�
attach_fhsz--secret-keyringr#z	--decrypt�rb)rE�statusrGrH))�	status_fp�closed�tempfile�
TemporaryFiler�defaultrA�	logger_fp�	stderr_fp�name�
byte_countrr(rrr)r,�meta_interactiver-r.r �	use_agentrr*r+r�default_keyrrrrr/�openr0�write�close�	gpg_inputr�
gpg_output�gpg_process�encrypt)
r!r^�encrypt_path�profiler8r9�cmdlistr�	gnupg_fhs�p1rrrr"xs�

��






��

��
zGPGFile.__init__���cCsPz|j�|�}|dur|jt|�7_W|SW|Sty'|��Y|Sw�N)r\�readrT�len�	Exception�
gpg_failed)r!�lengthr:rrrrf�s��
�zGPGFile.readcCspz)|j�|�}|dur'tjjdkr|j|7_W|S|jt|�7_W|SW|Sty7|��Y|Sw)N�)	r[rY�sys�version_info�majorrTrgrhri)r!�bufr:rrrrY�s���
�z
GPGFile.writecCs|jSre)rT�r!rrr�tell�szGPGFile.tellcCsH|jrJ�||jksJd||jf��||jkr"|�||j�dSdS)Nz%d < %d)r^rTrf)r!�offsetrrr�seeks


�zGPGFile.seekcCs�d}|d7}|j|jfD]6}|�d�|D],}z|t|��t��d�d7}WqtyA}z||��d7}WYd}~qd}~wwq|d7}|�d�dksRt	|��d	S)
NzGPG Failed, see log below:
z===== Begin GnuPG log =====
r�replace�
z===== End GnuPG log =====
zinvalid packet (ctb=14)rdr)
rQrRrsr�strip�locale�getpreferredencodingrh�findr)r!�msg�fpr;�errrris 
 ���zGPGFile.gpg_failedcCs |jr4z|j��Wn
ty|��Ynw|jr|��z|j��WnZty3|��YnNwd}|rPz|j	�
t�}Wn
tyM|��Ynw|s8z|j	��Wn
tyd|��Ynw|jrl|��z|j��Wn
ty�|��Ynw|j��|j
��d|_dS)NrB)r^r[rZrhrirL�
set_signaturer]�waitr\rf�	blocksizerQrRrM)r!r:rrrrZsH������


z
GPGFile.closecCs^|j�d�|j��}t�d|tj�}|sd|_dSt|�d��dks%J�|�d��	�|_dS)z�
        Set self.signature to signature keyID

        This only applies to decrypted files.  If the file was not
        signed, set self.signature to None.
        rs^\[GNUPG:\] GOODSIG ([0-9A-F]*)NrB�)
rLrsrfr=r4�M�	signaturergr6�decode)r!�
status_buf�matchrrrr}:s
�
zGPGFile.set_signaturecCs|jsJ�|jS)z=
        Return  keyID of signature, or None if none
        )rMr�rprrr�
get_signatureKs
zGPGFile.get_signatureN)rd)
r
rrrr"rfrYrqrsrirZr}r�rrrrr@ts
r	"r@���@cs�ddlm}�fdd�}�fdd�}|d}||}	td|���|�}
d}zD	|	|�}||��kr3nz|��j}
WntyEd	}Ynw|
�|
�q'|
�|�	��|sc|�}||krc||||
�|
�
�|WStyu|
�
��w)
aJ
    Write GPG compressed file of given size

    This function writes a gpg compressed file by reading from the
    input iter and writing to filename.  When it has read an amount
    close to the size limit, it "tops off" the incoming data with
    incompressible data, to try to hit the limit exactly.

    block_iter should have methods .next(size), which returns the next
    block of data, which should be at most size bytes long.  Also
    .get_footer() returns a string to write at the end of the input
    file.  The footer should have max length max_footer_size.

    Because gpg uses compression, we don't assume that putting
    bytes_in bytes into gpg will result in bytes_out = bytes_in out.
    However, do assume that bytes_out <= bytes_in approximately.

    Returns true if succeeded in writing until end of block_iter.
    r)�pathcs.t�d�}t�||j|�|ksJ�|��dS)z�
        Add bytelen of incompressible data to to_gpg_fp

        In this case we take the incompressible data from the
        beginning of filename (it should contain enough because size
        >> largest block size).
        rJN)rXr�copyfileobjr[rZ)�bytelen�file�incompressible_fp��filenamerr�top_offms
zGPGWriteFile.<locals>.top_offcst���jSre)�os�stat�st_sizerr�rr�get_current_sizeysz&GPGWriteFile.<locals>.get_current_sizei�TrB)�	duplicityr�r@�Path�
get_read_size�__next__�data�
StopIterationrY�
get_footerrZrh)�
block_iterr�r`�size�max_footer_sizer�r�r��target_size�	data_sizer��at_end_of_blockiter�bytes_to_gor��cursizerr�r�GPGWriteFileSs>
�
��r�Tc
Cs�Gdd�dt�}|t|d��}|rt�ddd|�}n|}d}	||j}||��kr+nzt|�}	Wnty<d}Ynw|�|	j	�q|�
�sL|�
�rNJ�|S)	a�
    Write gzipped compressed file of given size

    This is like the earlier GPGWriteFile except it writes a gzipped
    file instead of a gpg'd file.  This function is somewhat out of
    place, because it doesn't deal with GPG at all, but it is very
    similar to GPGWriteFile so they might as well be defined together.

    The input requirements on block_iter and the output is the same as
    GPGWriteFile (returns true if wrote until end of block_iter).
    c@s(eZdZdZdd�Zdd�Zdd�ZdS)	z"GzipWriteFile.<locals>.FileCountedzP
        Wrapper around file object that counts number of bytes written
        cSs||_d|_dS)Nr)�fileobjrT)r!r�rrrr"�s
z+GzipWriteFile.<locals>.FileCounted.__init__cSs"|j�|�}|jt|�7_|Sre)r�rYrTrg)r!ro�resultrrrrY�sz(GzipWriteFile.<locals>.FileCounted.writecSs
|j��Sre)r�rZrprrrrZ�s
z(GzipWriteFile.<locals>.FileCounted.closeN)r
rrrr"rYrZrrrr�FileCounted�s
r�rFN�rTrB)rrX�gzip�GzipFilerTr�rr�rYr�rZ)
r�r�r��gzippedr��file_counted�outfiler�r��	new_blockrrr�
GzipWriteFile�s(
��r�FcCst||||�S)a�
    Write plain uncompressed file of given size

    This is like the earlier GPGWriteFile except it writes a gzipped
    file instead of a gpg'd file.  This function is somewhat out of
    place, because it doesn't deal with GPG at all, but it is very
    similar to GPGWriteFile so they might as well be defined together.

    The input requirements on block_iter and the output is the same as
    GPGWriteFile (returns true if wrote until end of block_iter).
    )r�)r�r�r�r�rrr�PlainWriteFile�sr�rBcCsv|�d�}|dkr
t�}n|dkrt�}nJd|f��	|�t�}|s%n|�|�q|��r1J�|r7|��S|��S)z�
    Return hash of path

    hash should be "MD5" or "SHA1".  The output will be in hexadecimal
    form if hex is true, and in text (base64) otherwise.
    rJ�SHA1�MD5rzUnknown hash %s)	rXr	r
rfr�updaterZ�	hexdigest�digest)�hashr��hexr{�hash_objrorrr�get_hash�s 


�r�)r�r�)r�T)r�FrC)r�builtinsrrrr�rlrNr=r�rwr�rrrr�hashlibr	r
�ImportError�sharrrhrrr@r�r�r�r�rrrr�<module>s@�8a
�
G
3

https://t.me/RX1948 - 2025