HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/conch/ssh/__pycache__/filetransfer.cpython-38.pyc
U

\�[���@s$ddlmZmZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZddlmZmZddlmZmZmZmZmZGd	d
�d
ej�ZGdd�de�ZGd
d�de�Zee
�Gdd�d��ZGdd�d�ZGdd�de �Z!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,d Z-d!Z.d"Z/d#Z0d$Z1d%Z2d&Z3d'Z4d(Z5d)Z6d*Z7d+Z8d,Z9d-Z:d.Z;d/Z<dZ=dZ>e>Z?dZ@dZAd0ZBdZCdZDdZEdZFdZGdZHdZIdZJdZKd$ZLd1ZMd2ZNdZOdZPdZQdZRdZSdZTdZUdZVdZWdZXeSZYeSZZe[�Z\e]e\�^��D],Z_e_�`d3��r�e\e_Zae_dd�ejbea<�q�[\[_[adS)4�)�division�absolute_importN)�implementer)�ISFTPServer�	ISFTPFile)�NS�getNS)�defer�protocol)�failure�log)�_PY3�range�
itervalues�nativeString�
networkStringc@s<eZdZdZiZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dS)
�FileTransferBase)�cCsd|_d|_dS�N�)�bufZotherVersion��self�r�@/usr/lib/python3/dist-packages/twisted/conch/ssh/filetransfer.py�__init__szFileTransferBase.__init__cCs&|j�t�dt|�d|�|�dS)N�!LB�)Z	transport�write�struct�pack�len)r�kind�datarrr�
sendPacket"szFileTransferBase.sendPacketcCs6|j|7_t|j�dk�r2t�d|jdd��\}}t|j�d|krNdS|jdd|�|jd|d�}|_|j�|d�}|s�t�d|�qt|d�	|�d�}|�st�d�	|��t�t
|dd���t�d|dd��\}|�|td�	|��qz||�Wqt
k
�r.t��YqYqXqdS)	N�r�zno packet type forz	packet_{}znot implemented: {}�!Lzdon't understand {})rr!r�unpack�packetTypes�getr�msg�getattr�format�repr�_sendStatus�FX_OP_UNSUPPORTED�	Exception�err)rr#�lengthr"Z
packetType�fZreqIdrrr�dataReceived&s0(�zFileTransferBase.dataReceivedcCs�t�d|dd��\}i}|dd�}|t@tkr\t�d|dd��\}||d<|dd�}|t@tkr�t�d|dd��\}}||d<||d<|dd�}|t@tkr�t�d|dd��\}||d	<|dd�}|t@tk�rt�d|dd��\}}	||d
<|	|d<|dd�}|t@tk�r~t�d|dd��\}
|dd�}t|
�D]0}t|�\}}t|�\}
}|
|d�	t
|��<�qL||fS)
Nr'r&�!Q��size�!2L�uid�gid�permissions�atime�mtimezext_{})rr(�FILEXFER_ATTR_SIZE�FILEXFER_ATTR_OWNERGROUP�FILEXFER_ATTR_PERMISSIONS�FILEXFER_ATTR_ACMODTIME�FILEXFER_ATTR_EXTENDEDrrr-r)rr#�flags�attrsr8r:r;Zpermsr=r>Z
extendedCount�iZextendedTypeZextendedDatarrr�_parseAttributesAs<�z!FileTransferBase._parseAttributescCs:d}d}d|kr,|t�d|d�7}|tO}d|kr^d|kr^|t�d|d|d�7}|tO}d|kr�|t�d	|d�7}|tO}d
|kr�d|kr�|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)Nrrr8r6r:r;r9r<r'r=r>Zext_r&)
rr r?r@rArB�
startswithrr�appendr!�joinrC)rrErDr#Zextended�kZextType�extDatarrr�_packAttributesbs2
z FileTransferBase._packAttributesN)
�__name__�
__module__�__qualname__�versionsr)rr$r5rGrMrrrrrs!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#Zavatarrrrr�s

zFileTransferServer.__init__c
Cs�t�d|dd��\}tt|j�|g�|_|dd�}i}|rbt|�\}}t|�\}}|||<q<|j�||�}d}|�	�D]\}}	|t
|�t
|	�7}q||�tt�
d|j�|�dS�Nr'r&r)rr(�min�listrQ�versionrrTZ
gotVersion�itemsrr$�FXP_VERSIONr )
rr#rZZext�extNamerLZourExtZ
ourExtDatarK�vrrr�packet_INIT�s
�zFileTransferServer.packet_INITcCs�|dd�}|dd�}t|�\}}t�d|dd��\}|dd�}|�|�\}}|dksjtd�|���t�|jj	|||�}|�
|j|�|�|j
|d�dS)Nr&r'rzstill have data in OPEN: {!r}sopen failed)rrr(rG�AssertionErrorr-r	�
maybeDeferredrT�openFile�addCallback�_cbOpenFile�
addErrback�	_ebStatus)rr#�	requestId�filenamerDrE�drrr�packet_OPEN�szFileTransferServer.packet_OPENcCsDttt|���}||jkr"td��||j|<|�t|t|��dS)Nzid already open)r�str�hashrU�KeyErrorr$�
FXP_HANDLEr)r�fileObjrgZfileIdrrrrd�s


zFileTransferServer._cbOpenFilecCs�|dd�}|dd�}t|�\}}|dks:td�|���||jkr||j|}t�|j�}|�|j||�|�	|j
|d�n\||jkr�|j|d}t�|j�}|�|j||d�|�	|j
|d�n|�t
�t��|�dS)Nr&rzstill have data in CLOSE: {!r}sclose failedrr)rr`r-rUr	ra�closerc�_cbClosererfrVZ_ebCloser�Failurerm)rr#rg�handlerori�dirObjrrr�packet_CLOSE�s


zFileTransferServer.packet_CLOSErcCs(|r|j|=n|j|=|�|td�dS)Nsfile closed)rVrUr/�FX_OK)r�resultrsrgZisDirrrrrq�s
zFileTransferServer._cbClosecCs�|dd�}|dd�}t|�\}}t�d|dd��|dd�\}}}|dks`td�|���||jkr�|�t�t	��|�n8|j|}t
�|j||�}|�
|j|�|�|j|d�dS)Nr&�!QL�rzstill have data in READ: {!r}sread failed)rrr(r`r-rUZ_ebReadrrrrmr	ra�	readChunkrc�_cbReadrerf)rr#rgrs�offsetr3rorirrr�packet_READ�s&

zFileTransferServer.packet_READcCs&|dkrt��|�t|t|��dSr)�EOFErrorr$�FXP_DATAr�rrwrgrrrr{�szFileTransferServer._cbReadcCs�|dd�}|dd�}t|�\}}t�d|dd��\}|dd�}t|�\}}|dkshtd�|���||jkr�|�t�t	��|�n:|j|}t
�|j||�}|�
|j|d�|�|j|d�dS)Nr&r6r7rzstill have data in WRITE: {!r}swrite succeededswrite failed)rrr(r`r-rUZ_ebWriterrrrmr	ra�
writeChunkrc�	_cbStatusrerf)rr#rgrsr|Z	writeDatarorirrr�packet_WRITE�s

zFileTransferServer.packet_WRITEcCsn|dd�}|dd�}t|�\}}|dks:td�|���t�|jj|�}|�|j|d�|�	|j
|d�dS)Nr&rzstill have data in REMOVE: {!r}sremove succeededs
remove failed)rr`r-r	rarT�
removeFilercr�rerf)rr#rgrhrirrr�
packet_REMOVE�sz FileTransferServer.packet_REMOVEcCs||dd�}|dd�}t|�\}}t|�\}}|dksFtd�|���t�|jj||�}|�|j|d�|�	|j
|d�dS)Nr&rzstill have data in RENAME: {!r}srename succeededs
rename failed)rr`r-r	rarT�
renameFilercr�rerf)rr#rgZoldPathZnewPathrirrr�
packet_RENAME�sz FileTransferServer.packet_RENAMEcCs~|dd�}|dd�}t|�\}}|�|�\}}|dksHtd�|���t�|jj||�}|�|j	|d�|�
|j|d�dS)Nr&rzstill have data in MKDIR: {!r}smkdir succeededsmkdir failed)rrGr`r-r	rarT�
makeDirectoryrcr�rerf�rr#rg�pathrErirrr�packet_MKDIRszFileTransferServer.packet_MKDIRcCsn|dd�}|dd�}t|�\}}|dks:td�|���t�|jj|�}|�|j|d�|�	|j
|d�dS)Nr&rzstill have data in RMDIR: {!r}srmdir succeededsrmdir failed)rr`r-r	rarT�removeDirectoryrcr�rerf�rr#rgr�rirrr�packet_RMDIRszFileTransferServer.packet_RMDIRcCsl|dd�}|dd�}t|�\}}|dks:td�|���t�|jj|�}|�|j|�|�	|j
|d�dS)Nr&rz still have data in OPENDIR: {!r}sopendir failed)rr`r-r	rarT�
openDirectoryrc�_cbOpenDirectoryrerfr�rrr�packet_OPENDIRsz!FileTransferServer.packet_OPENDIRcCsLttt|���}||jkr"td��|t|�g|j|<|�t|t|��dS)Nzalready opened this directory)	rrkrlrVrm�iterr$rnr)rrtrgrsrrrr�#s

z#FileTransferServer._cbOpenDirectorycCs�|dd�}|dd�}t|�\}}|dks:td�|���||jkrZ|�t�t��|�n<|j|\}}t�	|j
|g�}|�|j|�|�
|j|d�dS)Nr&rz still have data in READDIR: {!r}sscan directory failed)rr`r-rVrfrrrrmr	ra�_scanDirectoryrc�_cbSendDirectoryre)rr#rgrsrt�dirIterrirrr�packet_READDIR+s
z!FileTransferServer.packet_READDIRcCsjt|�dkrfzt|�}Wn tk
r8|s0t�|YSXt|tj�rZ|�|j||�dS|�	|�q|S)N�)
r!�next�
StopIterationr~�
isinstancer	�Deferredrc�_cbScanDirectoryrI)rr�r4�inforrrr�9s
z!FileTransferServer._scanDirectorycCs|�|�|�||�SrS)rIr�)rrwr�r4rrrr�Is
z#FileTransferServer._cbScanDirectoryc	Cs^d}|D]0\}}}|t|�7}|t|�7}||�|�7}q|�t|t�dt|��|�dS)Nrr')rrMr$�FXP_NAMErr r!)rrwrgr#rh�longnamerErrrr�Ns��z#FileTransferServer._cbSendDirectoryrcCsn|dd�}|dd�}t|�\}}|dks:td�|���t�|jj||�}|�|j|�|�	|j
|d�dS)Nr&rz#still have data in STAT/LSTAT: {!r}sstat/lstat failed)rr`r-r	rarT�getAttrsrc�_cbStatrerf)rr#�followLinksrgr�rirrr�packet_STATXszFileTransferServer.packet_STATcCs|�|d�dS�Nr)r�)rr#rrr�packet_LSTATbszFileTransferServer.packet_LSTATcCs�|dd�}|dd�}t|�\}}|dks:td�|���||jkrb|�t�td�|���|�n4|j|}t�	|j
�}|�|j|�|�
|j|d�dS)Nr&rzstill have data in FSTAT: {!r}z{} not in self.openFilessfstat failed)rr`r-rUrfrrrrmr	rar�rcr�re)rr#rgrsrorirrr�packet_FSTATfs

��
zFileTransferServer.packet_FSTATcCs||�|�}|�t|�dSrS)rMr$�	FXP_ATTRS)rrwrgr#rrrr�uszFileTransferServer._cbStatcCs�|dd�}|dd�}t|�\}}|�|�\}}|dkrJt�d�|��t�|jj||�}|�	|j
|d�|�|j|d�dS)Nr&rz&WARN: still have data in SETSTAT: {!r}ssetstat succeededssetstat failed)
rrGrr+r-r	rarT�setAttrsrcr�rerfr�rrr�packet_SETSTATzsz!FileTransferServer.packet_SETSTATcCs�|dd�}|dd�}t|�\}}|�|�\}}|dksHtd�|���||jkrh|�t�t��|�n8|j|}t	�
|j|�}|�|j
|d�|�|j|d�dS)Nr&rz!still have data in FSETSTAT: {!r}sfsetstat succeededsfsetstat failed)rrGr`r-rUrfrrrrmr	rar�rcr�re)rr#rgrsrErorirrr�packet_FSETSTAT�s

z"FileTransferServer.packet_FSETSTATcCsl|dd�}|dd�}t|�\}}|dks:td�|���t�|jj|�}|�|j|�|�	|j
|d�dS)Nr&rz!still have data in READLINK: {!r}sreadlink failed)rr`r-r	rarT�readLinkrc�_cbReadLinkrerfr�rrr�packet_READLINK�s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)	rr	rarT�makeLinkrcr�rerf)rr#rg�linkPath�
targetPathrirrr�packet_SYMLINK�sz!FileTransferServer.packet_SYMLINKcCsl|dd�}|dd�}t|�\}}|dks:td�|���t�|jj|�}|�|j|�|�	|j
|d�dS)Nr&rz!still have data in REALPATH: {!r}srealpath failed)rr`r-r	rarT�realPathrcr�rerfr�rrr�packet_REALPATH�sz"FileTransferServer.packet_REALPATHcCs`|dd�}|dd�}t|�\}}t�|jj||�}|�|j|�|�|j|d|d�dS)Nr&s	extended s failed)	rr	rarT�extendedRequestrc�_cbExtendedrerf)rr#rgr]rLrirrr�packet_EXTENDED�s

�z"FileTransferServer.packet_EXTENDEDcCs|�t||�dSrS)r$�FXP_EXTENDED_REPLY)rr#rgrrrr��szFileTransferServer._cbExtended�request succeededcCs|�|t|�dSrS)r/rv)rrwrgr+rrrr��szFileTransferServer._cbStatus�request failedcCs
t}|}t|jttf�rx|jjtjkr8t}t|jj	�}q�|jjtj
krXt}t|jj	�}q�|jjtjkrlt
}q�t�|�n�t|jt�r�t}|jjr�t|jjd�}nVt|jt�r�t}|jjr�t|jjd�}n,t|jt�r�|jj}t|jj�}n
t�|�|�|||�dSr�)�
FX_FAILUREr��value�IOError�OSError�errnoZENOENT�FX_NO_SUCH_FILEr�strerrorZEACCES�FX_PERMISSION_DENIEDZEEXIST�FX_FILE_ALREADY_EXISTSrr2r~�FX_EOF�args�NotImplementedErrorr0�	SFTPError�code�messager/)r�reasonrgr+r�r�rrrrf�s2
zFileTransferServer._ebStatusrcCs8|t�d|�}|t|�7}|t|�7}|�t|�dS)z=
        Helper method to send a FXP_STATUS message.
        r'N)rr rr$�
FXP_STATUS)rrgr�r��langr#rrrr/�szFileTransferServer._sendStatuscCsD|j��D]}|��q
i|_|j��D]\}}|��q(i|_dS)z9
        Clean all opened files and directories.
        N)rU�valuesrprV)rr�rortr�rrr�connectionLost�s

z!FileTransferServer.connectionLost)NN)r)r)r�)r�)r)&rNrOrPrr_rjrdrurqr}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�rfr/r�rrrrrRsF
















rRc@s�eZdZifdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
d7dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6S)8�FileTransferClientcCs t�|�i|_d|_i|_dS)zq
        @param extData: a dict of extended_name : extended_data items
        to be sent to the server.
        rN)rrrL�counter�openRequests)rrLrrrrs
zFileTransferClient.__init__cCsJt�dt|j��}t|j�D]\}}|t|�t|�7}q|�t|�dS)Nr')	rr �maxrQrrLrr$�FXP_INIT)rr#rKr^rrr�connectionMadesz!FileTransferClient.connectionMadecCsDt�d|j�|}t��}||j|j<|jd7_|�||�|S)Nr'r)rr r�r	r�r�r$)rr+r#rirrr�_sendRequestszFileTransferClient._sendRequestcCs8t�d|dd��\}|j|}|j|=||dd�fS�Nr'r&)rr(r�)rr#�idrirrr�
_parseRequests
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.
        r')	rrr rMr��FXP_OPENrc�
_cbOpenHandle�
ClientFile)rrhrDrEr#rirrrrb"s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)rrsZhandleClassr��cbrrrr�Es
z FileTransferClient._cbOpenHandlecCs|�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)rrhrrrr�Ws	zFileTransferClient.removeFilecCs|�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)rZoldpath�newpathrrrr�cszFileTransferClient.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_MKDIRrrM)rr�rErrrr�qs
z FileTransferClient.makeDirectorycCs|�tt|��S)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_OPENDIRrrcr��ClientDirectory�rr�rirrrr��sz FileTransferClient.openDirectoryrcCs|r
t}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_LSTATr�r)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.
        )rrMr��FXP_SETSTAT)rr�rEr#rrrr��szFileTransferClient.setAttrscCs|�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_READLINKrrc�_cbRealPathr�rrrr��s
zFileTransferClient.readLinkcCs|�tt|�t|��S)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.makeLinkcCs|�tt|��}|�|j�S)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_REALPATHrrcr�r�rrrr��s
zFileTransferClient.realPathcCs |d\}}}tr|�d�}|S)Nrzutf-8)r
�decode)rrwr�r�rErrrr�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)rZrequestr#rrrr�sz"FileTransferClient.extendedRequestcCsbt�d|dd��\}|dd�}i}|rLt|�\}}t|�\}}|||<q&||_|�||�dSr�)rr(rrZ�gotServerVersion)rr#rZrirKr^rrr�packet_VERSIONs
z!FileTransferClient.packet_VERSIONcCs�|�|�\}}t�d|dd��\}|dd�}t|�dkrht|�\}}t|�dkrbt|�\}}qpd}nd}d}|tkr�|�||f�nF|tkr�|�t	|��n.|t
kr�|�t|��n|�t|t
|�|��dSrW)r�rr(r!rrv�callbackr�Zerrbackr~r0r�r�r)rr#rir�r+r�rrr�
packet_STATUS"s"z FileTransferClient.packet_STATUScCs(|�|�\}}t|�\}}|�|�dSrS)r�rr�)rr#rirs�_rrr�
packet_HANDLE9sz FileTransferClient.packet_HANDLEcCs$|�|�\}}|�t|�d�dSr�)r�r�r�rr#rirrr�packet_DATA?szFileTransferClient.packet_DATAc	Cs�|�|�\}}t�d|dd��\}|dd�}g}t|�D]:}t|�\}}t|�\}}|�|�\}}|�|||f�q<|�|�dSr�)r�rr(rrrGrIr�)	rr#ri�count�filesrFrhr�rErrr�packet_NAMEDszFileTransferClient.packet_NAMEcCs&|�|�\}}|�|�|�d�dSr�)r�r�rGr�rrr�packet_ATTRSQszFileTransferClient.packet_ATTRScCs|�|�\}}|�|�dSrS)r�r�r�rrr�packet_EXTENDED_REPLYVsz(FileTransferClient.packet_EXTENDED_REPLYcCsdS)aM
        Called when the client sends their version info.

        @param otherVersion: 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)rZ
serverVersionrLrrrr�[sz#FileTransferClient.gotServerVersionN)r)rNrOrPrr�r�r�rbr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s4	##

r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r�cCs||_t|�|_dSrS)�parentrrs�rr�rsrrrriszClientFile.__init__cCs|j�t|j�SrS)r�r��	FXP_CLOSErsrrrrrpnszClientFile.closecCs"|jt�d||�}|j�t|�S)Nrx)rsrr r�r��FXP_READ)rr|r3r#rrrrzrszClientFile.readChunkcCs(|jt�d|�t|�}|j�t|�S)Nr6)rsrr rr�r��	FXP_WRITE)rr|�chunkr#rrrr�wszClientFile.writeChunkcCs|j�t|j�SrS)r�r��	FXP_FSTATrsrrrrr�|szClientFile.getAttrscCs |j|j�|�}|j�t|�SrS)rsr�rMr�r)rrEr#rrrr��szClientFile.setAttrsN)	rNrOrPrrprzr�r�r�rrrrr�gsr�c@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZeZdd�Z	d
d�Z
dS)r�cCs||_t|�|_g|_dSrS)r�rrs�
filesCacher�rrrr�s
zClientDirectory.__init__cCs|j�t|j�SrS)r�r��FXP_READDIRrsrrrr�read�szClientDirectory.readcCs.|jdkrt�d�S|j�t|j�}d|_|SrS)rsr	Zsucceedr�r�r��rrirrrrp�s


zClientDirectory.closecCs|SrSrrrrr�__iter__�szClientDirectory.__iter__cCsNtjdtdd�|jr"|j�d�S|jdkr2t��|��}|�|j|j	�|S)NzeUsing twisted.conch.ssh.filetransfer.ClientDirectory as an iterator was deprecated in Twisted 18.9.0.�)�category�
stacklevelr)
�warnings�warn�DeprecationWarningr�popr�rZaddCallbacks�
_cbReadDir�
_ebReadDirrrrr�__next__�s�
zClientDirectory.__next__cCs|dd�|_|dS)Nrr)r)r�namesrrrr�szClientDirectory._cbReadDircCs|�t�d|_t�t��SrS)Ztrapr~rrrrr�)rr�rrrr�s
zClientDirectory._ebReadDirN)rNrOrPrrrprrr�rrrrrrr��sr�c@s.eZdZd	dd�Zdd�Zee�Zdd�ZdS)
r��cCs t�|�||_||_||_dSrS)r1rr��_messager�)rZ	errorCodeZerrorMessager�rrrr�s
zSFTPError.__init__cCs|jS)zX
        A string received over the network that explains the error to a human.
        )rrrrrr��s	zSFTPError.messagecCsd�|j|j�S)NzSFTPError {}: {})r-r�r�rrrr�__str__�szSFTPError.__str__N)r)rNrOrPrr��propertyrrrrrr��s

r�rrrr&r%��r7�	�
�ry�
��������e�f�g�h�i����l� �@ZFXP_)cZ
__future__rrr�rrZzope.interfacerZtwisted.conch.interfacesrrZtwisted.conch.ssh.commonrrZtwisted.internetr	r
Ztwisted.pythonrrZtwisted.python.compatr
rrrrZProtocolrrRr�r�r�r1r�r�r\r�r�r�rr�rr�ZFXP_FSETSTATr�rr�r�r�r�r�r�r�r�r�rnrr�r�r�r�r?ZFILEXFER_ATTR_UIDGIDr@rArBrCZFILEXFER_TYPE_REGULARZFILEXFER_TYPE_DIRECTORYZFILEXFER_TYPE_SYMLINKZFILEXFER_TYPE_SPECIALZFILEXFER_TYPE_UNKNOWNZFXF_READZ	FXF_WRITEZ
FXF_APPENDZ	FXF_CREATZ	FXF_TRUNCZFXF_EXCLZFXF_TEXTrvr�r�r�r�ZFX_BAD_MESSAGEZFX_NO_CONNECTIONZFX_CONNECTION_LOSTr0r�ZFX_NOT_A_DIRECTORYZFX_FILE_IS_A_DIRECTORY�globals�grY�keysr�rHr�r)rrrr�<module>s�hk5