Ϫf”ddlZddlZddlZddlZddlmZddlmZddlm Z m Z ddl m Z m Z ddlmZmZmZddlmZddlmZdd lmZmZGd d ej2ZGd d eZGddeZee GddZGddZGddeZ 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;dZdZ?dZ@d1ZAdZBdZCdZDdZEdZFdZGdZHdZIdZJd%ZKd2ZLd3ZMdZNdZOdZPdZQdZRdZSdZTdZUdZVd ZWeRZXeRZYeZZ[e\e[jD]+Z^e^jd4se[e^Z`e^ddeje`<-[[[^[`y)5N)Dict) implementer) ISFTPFile ISFTPServer)NSgetNS)defererrorprotocol)Logger)failure) nativeString networkStringcheZdZUeZdZiZeee fe d<dZ dZ dZ dZdZfdZxZS) FileTransferBase) packetTypesc d|_d|_yN)buf otherVersionselfs @/usr/lib/python3/dist-packages/twisted/conch/ssh/filetransfer.py__init__zFileTransferBase.__init__s rc|jjtjdt |dz||zy)Nz!LB) transportwritestructpacklen)rkinddatas r sendPacketzFileTransferBase.sendPacket"s. V[[D A tDtKLrc2|xj|z c_t|jdk\r<|jdd}tjd|\}}}t|jd|zkry|jdd|z|jd|zdc}|_|jj |d}|s|j jd|t|d|d}|s=|j jd||dd |j|td ||j jd ||  ||t|jdk\r;yy#t$r!|j jd |YwxYw)N z!LBLzno 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!unpackrget_loginfogetattr _sendStatusFX_OP_UNSUPPORTED Exceptionr )rr%headerlengthr$r-r,fs r dataReceivedzFileTransferBase.dataReceived%s D$((mq XXbq\F"(--"? FD%488}q6z) "XXa!f*5txxF 7MND$())--dD9J :F |4d;A A)ab   ,0A*.N IINN=%    $W$((mq X  !!B)"  sE,,&FFctjd|dd\}i}|dd}|tztk(r%tjd|dd\}||d<|dd}|tztk(r+tjd|dd\}}||d<||d<|dd}|tztk(r%tjd|dd\}||d <|dd}|t zt k(r+tjd|dd\}} ||d <| |d <|dd}|t zt k(r]tjd|dd\} |dd}t| D]/} t|\} }t|\} }| |d t| <1||fS) N!Lr)!Qsize!2Luidgid permissionsatimemtimeext_) r!r.FILEXFER_ATTR_SIZEFILEXFER_ATTR_OWNERGROUPFILEXFER_ATTR_PERMISSIONSFILEXFER_ATTR_ACMODTIMEFILEXFER_ATTR_EXTENDEDrangerr)rr%flagsattrsr>r@rApermsrCrD extendedCounti extendedType extendedDatas r_parseAttributesz!FileTransferBase._parseAttributes`s==tBQx0ABx % %); ;mmD$r(3GT E&M8D + +/G G}}UD!H5HCE%LE%L8D , ,0I I}}T484HU#(E- 8D * *.E E!==Ra9LE5"E'N"E'N8D ) )-C C%}}T48< ]8D=) J',T{$t',T{$t=I\,789: Jd{rcd}d}d|vr%|tjd|dz }|tz}d|vr-d|vr)|tjd|d|dz }|tz}d|vr%|tjd |dz }|tz}d |vr-d |vr)|tjd|d |d z }|t z}g}|D]M}|j d stt|d d}t||}|j||zO|r?|tjd t|z }|dj|z }|tz}tjd ||zS)Nrrr>r<r@rAr?rBr;rCrDrEr)) r!r"rFrGrHrI startswithrrappendr#joinrJ)rrMrLr%extendedkextTypeextDatas r_packAttributesz FileTransferBase._packAttributessy U? FKKeFm4 4D ' 'E E>eun FKKuU|U5\B BD - -E E ! FKKeM&:; ;D . .E e 5 0 FKKuW~uW~F FD , ,E 3A||F#]1QR512U1X,' 12  3  FKKc(m4 4D CHHX& &D + +E{{4'$..rc2t||d|_y)zJ Called when connection to the remote subsystem was lost. FN)superconnectionLost connected)rreason __class__s rr_zFileTransferBase.connectionLosts v&r)__name__ __module__ __qualname__r r0versionsrrintstr__annotations__rr&r9rSr\r_ __classcell__)rbs@rrrsF 8DH"$Kc3h$!M9v>/6rrceZdZd%dZdZdZdZdZd&dZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZd'dZdZdZdZdZdZdZdZdZdZdZ d Z!d(d!Z"d)d"Z#d*d#Z$d$Z%y)+FileTransferServerNcjtj|t||_i|_i|_yN)rrrclient openFilesopenDirs)rr%avatars rrzFileTransferServer.__init__s*!!$'!&)  rctjd|dd\}tt|j|gz|_|dd}i}|r$t |\}}t |\}}|||<|r$|jj||}d}|jD]\}} |t|t| zz }!|jttjd|j |zyNr;r)r)r!r.minlistrfversionrro gotVersionitemsrr& FXP_VERSIONr") rr%rwextextNamer[ourExt ourExtDatarYvs r packet_INITzFileTransferServer.packet_INITs]]4bq2 4 .':; ABx!$KMGT!$KMGT"CL''5 LLN (DAq "Q%"Q%- 'J (  V[[t||%Dz%QRrc|dd}|dd}t|\}}tjd|dd\}|dd}|j|\}}|dk(s Jd|t j |j j|||}|j|j||j|j|dy)Nr)r;rzstill have data in OPEN: s open failed) rr!r.rSr maybeDeferredroopenFile addCallback _cbOpenFile addErrback _ebStatus)rr% requestIdfilenamerLrMds r packet_OPENzFileTransferServer.packet_OPENs!H ABxt$==tBQx0ABx++D1 ts{@7x@@{    4 4hu M d&& 2 T^^Y?rcttt|}||jvr t d||j|<|j t |t|zy)Nzid already open)rrhhashrpKeyErrorr& FXP_HANDLEr)rfileObjrfileIds rrzFileTransferServer._cbOpenFilesRs4=12 T^^ #,- -!(v  I6 $:;rc|dd}|dd}t|\}}|jjd|||dk(s Jd|||jvri|j|}t j |j }|j|j|||j|j|dy||jvrm|j|d}t j |j }|j|j||d|j|j|dytj}tj|}t!||} |jt#j$| |y) Nr)z!closing: {requestId!r} {handle!r})rhandlerzstill have data in CLOSE: s close failedrr)rr0r1rpr rcloser_cbCloserrrqerrnoENOENTosstrerrorOSErrorr Failure) rr%rrrrdirObjcodetexterrs r packet_CLOSEzFileTransferServer.packet_CLOSEsK!H ABxT{   /  s{A8AA{ T^^ #nnV,G##GMM2A MM$-- ; LLO D t}} $]]6*1-F##FLL1A MM$--A > LLO D<:rc|dd}|dd}t|\}}tjd|dd|ddc\}}}|dk(s Jd|||jvr.|j t j t|y|j|}tj|j||}|j|j||j|j|dy)Nr)!QL rzstill have data in READ: s read failed)rr!r.rp_ebReadr rrr r readChunkr_cbReadrr)rr%rroffsetr7rrs r packet_READzFileTransferServer.packet_READs!H ABxT{ !'ud3Bi!@$rs)$s{@7x@@{  ' LL4i @nnV,G##G$5$5vvFA MM$,, 2 LLN Crcf|dk(r t|jt|t|zyr)EOFErrorr&FXP_DATArrrrs rrzFileTransferServer._cbReads( S=*  )bj"89rc|dd}|dd}t|\}}tjd|dd\}|dd}t|\}}|dk(s Jd|||jvr.|j t j t|y|j|}tj|j||}|j|j|d|j|j|dy)Nr)r<r=rzstill have data in WRITE: swrite succeededs write failed)rr!r.rp_ebWriter rrr r writeChunkr _cbStatusrr)rr%rrr writeDatarrs r packet_WRITEzFileTransferServer.packet_WRITEs!H ABxT{ MM$Ra1 ABx+ 4s{A8AA{  ' MM'//(*5y AnnV,G##G$6$6 JA MM$..)5G H LLO Drc|dd}|dd}t|\}}|dk(s Jd|tj|jj|}|j |j |d|j|j|dy)Nr)rzstill have data in REMOVE: sremove succeededs remove failed) rr rro removeFilerrrr)rr%rrrs r packet_REMOVEz FileTransferServer.packet_REMOVEs!H ABxt$s{B9$BB{    6 6 A dnni1DE T^^Y0@Arc8|dd}|dd}t|\}}t|\}}|dk(s Jd|tj|jj||}|j |j |d|j|j|dy)Nr)rzstill have data in RENAME: srename succeededs rename failed) rr rro renameFilerrrr)rr%roldPathnewPathrs r packet_RENAMEz FileTransferServer.packet_RENAMEs!H ABxd d s{B9$BB{    6 6 I dnni1DE T^^Y0@ArcD|dd}|dd}t|\}}|j|\}}|dk(s Jd|tj|jj ||}|j |j|d|j|j|dy)Nr)rzstill have data in MKDIR: smkdir succeededs mkdir failed) rrSr rro makeDirectoryrrrrrr%rpathrMrs r packet_MKDIRzFileTransferServer.packet_MKDIR#s!H ABx4[ d++D1 ts{A8AA{    9 94 G dnni1CD T^^Y@rc|dd}|dd}t|\}}|dk(s Jd|tj|jj|}|j |j |d|j|j|dy)Nr)rzstill have data in RMDIR: srmdir succeededs rmdir failed) rr rroremoveDirectoryrrrrrr%rrrs r packet_RMDIRzFileTransferServer.packet_RMDIR-s!H ABx4[ ds{A8AA{    ; ;T B dnni1CD T^^Y@rc|dd}|dd}t|\}}|dk(s Jd|tj|jj|}|j |j ||j|j|dy)Nr)rzstill have data in OPENDIR: sopendir failed) rr rro openDirectoryr_cbOpenDirectoryrrrs rpacket_OPENDIRz!FileTransferServer.packet_OPENDIR6s!H ABx4[ ds{C:4(CC{    9 94 @ d++Y7 T^^Y0ABrcttt|}||jvr t d|t |g|j|<|j t|t|zy)Nzalready opened this directory) rrhrrqriterr&rr)rrrrs rrz#FileTransferServer._cbOpenDirectory?s[s4<01 T]] ":; ;!'f 6 f  I6 $:;rc|dd}|dd}t|\}}|dk(s Jd|||jvr.|jtjt |y|j|\}}t j|j|g}|j|j||j|j|dy)Nr)rzstill have data in READDIR: sscan directory failed) rrqrr rrr r_scanDirectoryr_cbSendDirectoryr)rr%rrrdirIterrs rpacket_READDIRz!FileTransferServer.packet_READDIRFs!H ABxT{ s{C:4(CC{  & NN7??8:6 B"mmF3OFG##D$7$7"EA MM$// ; LL4L Mrct|dkrd t|}t |t j r|j|j||y|j|t|dkrd|S#t$r |st|cYSwxYw)N) r#next StopIterationr isinstancer Deferredr_cbScanDirectoryrV)rrr8r1s rrz!FileTransferServer._scanDirectorySs!fsl G} $/  !6!6C!fsl! "N s A55B  B cH|j||j||Srn)rVr)rrrr8s rrz#FileTransferServer._cbScanDirectorybs! ""7A..rc d}|D]6\}}}|t|z }|t|z }||j|z }8|jt|t j dt |z|zy)Nrr;)rr\r&FXP_NAMEr!r"r#)rrrr%rlongnamerMs rrz#FileTransferServer._cbSendDirectoryfsw)/ 0 %Hh BxL D BxL D D((/ /D 0 )fkk$F .L"Lt"STrc|dd}|dd}t|\}}|dk(s Jd|tj|jj||}|j |j ||j|j|dy)Nr)rzstill have data in STAT/LSTAT: sstat/lstat failed) rr rrogetAttrsr_cbStatrr)rr% followLinksrrrs r packet_STATzFileTransferServer.packet_STATns!H ABx4[ ds{F=dXFF{    4 4dK H dllI. T^^Y0DErc(|j|dyNr)r)rr%s r packet_LSTATzFileTransferServer.packet_LSTATws q!rc|dd}|dd}t|\}}|dk(s Jd|||jvr2|jtjt |d|y|j|}t j|j}|j|j||j|j|dy)Nr)rzstill have data in FSTAT: z not in self.openFiless fstat failed) rrprr rrr rrrrr)rr%rrrrs r packet_FSTATzFileTransferServer.packet_FSTATzs!H ABxT{ s{A8AA{  ' NNF83I)J KL  nnV,G##G$4$45A MM$,, 2 LLO DrcX||j|z}|jt|yrn)r\r& FXP_ATTRS)rrrr%s rrzFileTransferServer._cbStats%4//77  4(rcj|dd}|dd}t|\}}|j|\}}|dk7r|jjd|t j |j j||}|j|j|d|j|j|dy)Nr)rz$Still have data in SETSTAT: {data!r})r%ssetstat succeededssetstat failed) rrSr0warnr rrosetAttrsrrrrrs rpacket_SETSTATz!FileTransferServer.packet_SETSTATs!H ABx4[ d++D1 t 3; IINNAN M    4 4dE B dnni1EF T^^Y0ABrc|dd}|dd}t|\}}|j|\}}|dk(s Jd|||jvr.|jt j t |y|j|}tj|j|}|j|j|d|j|j|dy)Nr)rzstill have data in FSETSTAT: sfsetstat succeededsfsetstat failed) rrSrprr rrr rrrrr)rr%rrrMrrs rpacket_FSETSTATz"FileTransferServer.packet_FSETSTATs!H ABxT{ ++D1 ts{D;D8DD{  ' NN7??8:6 BnnV,G##G$4$4e##u||3+' (=(=>##u||3- !!;"'# "  h /D||  ' (9(9!(<=  &9 :$D||  ' (9(9!(<=  i 0<<$$D#FLL$8$89G II  J#   D'2rc|tjd|z}|t|z }|t|z }|jt|y)z= Helper method to send a FXP_STATUS message. r;N)r!r"rr& FXP_STATUS)rrrrlangr%s rr3zFileTransferServer._sendStatussC6;;tT22 7  4  D)rctj|||jjD]}|j i|_|j jD]\}}|j i|_y)z{ Called when connection to the remote subsystem was lost. Clean all opened files and directories. N)rr_rpvaluesrrq)rrarrrs rr_z!FileTransferServer.connectionLostsp ''f5~~,,. G MMO #}}335 OFG LLN  r)NNr)r)srequest succeeded)srequest failed)r)&rcrdrerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr3r_rrrlrls S @<<4; D: E BBAAC< N /UF"E ) C HD>CDU>0%3N*rrlceZdZifdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zdd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZy)FileTransferClientcXtj|i|_d|_i|_y)zq @param extData: a dict of extended_name : extended_data items to be sent to the server. rN)rrr[counter openRequests)rr[s rrzFileTransferClient.__init__s( !!$'  rctjdt|j}|jj D]\}}|t |t |zz }!|jt|y)Nr;) r!r"maxrfr[rrr&FXP_INIT)rr%rYrs rconnectionMadez!FileTransferClient.connectionMades_{{4T]]!34LL'') "DAq BqEBqEM !D " $'rcNtj|||jrtj}|j |_tj|}|jr<|jj\}}|j||jr;yyy)zu Called when connection to the remote subsystem was lost. Any pending requests are aborted. N) rr_rr ConnectionLostr  __cause__r rpopitemerrback)rra requestErrorrequestFailure_deferreds rr_z!FileTransferClient.connectionLost%s ''f5   !//1L%+\\L "$__\:N##"//779 8  0## rcZ|js'tjtjSt j d|j|z}tj}||j|j<|xjdz c_|j|||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. r;r) r`r failr r%r!r"rrrr&)rrr%rs r _sendRequestzFileTransferClient._sendRequest:s}~~::e2245 5{{4.5 NN *+$,,'   T"rc~tjd|dd\}|j|}|j|=||ddfSNr;r))r!r.r)rr%idrs r _parseRequestz FileTransferClient._parseRequestNsH dD!H-   b !   b !$qr({rct|tjd|z|j|z}|j t |}|j |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;) rr!r"r\r/FXP_OPENr _cbOpenHandle ClientFile)rrrLrMr%rs rrzFileTransferClient.openFileTsZ:(|fkk$669M9Me9TT   h - d((*h?rc&|||}||_|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 handleClassr9cbs rr6z FileTransferClient._cbOpenHandlevsv & rc@|jtt|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)rrs rrzFileTransferClient.removeFiles  R\::rcX|jtt|t|zS)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)roldpathnewpaths rrzFileTransferClient.renameFiles$  R[2g;-FGGrcd|jtt||j|zS)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_MKDIRrr\)rrrMs rrz FileTransferClient.makeDirectorys+  BtHt7K7KE7R,RSSrc@|jtt|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)rrs rrz"FileTransferClient.removeDirectorys  BtH55rc|jtt|}|j|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_OPENDIRrrr6ClientDirectoryrrrs rrz FileTransferClient.openDirectorys5<   k2d8 4 d((/4@rcV|rt}nt}|j|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)rrrms rrzFileTransferClient.getAttrss( AA  BtH--rcht||j|z}|jt|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. )rr\r/ FXP_SETSTAT)rrrMr%s rrzFileTransferClient.setAttrss0$x$..u55  d33rcv|jtt|}|j|jS)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 _cbRealPathrIs rrzFileTransferClient.readLink/   lBtH 5}}T--..rcX|jtt|t|zS)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)rrrs rrzFileTransferClient.makeLink s$  blR ^.KLLrcv|jtt|}|j|jS)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_REALPATHrrrRrIs rrzFileTransferClient.realPathrSrc:|d\}}}|jd}|S)Nrzutf-8)decode)rrr9rrMs rrRzFileTransferClient._cbRealPath(s% &q h{{7# rcF|jtt||zS)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)rrequestr%s rrz"FileTransferClient.extendedRequest-s   r'{T/ABBrctjd|dd\}|dd}i}|r$t|\}}t|\}}|||<|r$||_|j ||yr1)r!r.rrwgotServerVersion)rr%rwrrYrs rpacket_VERSIONz!FileTransferClient.packet_VERSION;sn]]4bq2 ABx DkGAtDkGAtAaD  gq)rc|j|\}}tjd|dd\}|dd}t|dk\r.t |\}}t|dk\rt |\}}nd}nd}d}|t k(r|j ||fy|tk(r|jt|y|tk(r|jt|y|jt|t||yrt)r3r!r.r#rrcallbackrr(rr4rrr)rr%rrrrs r packet_STATUSz FileTransferClient.packet_STATUSFs$$T*4--d2Ah/ABx t9>d IC4yA~"4[ dCD 5= JJT{ # V^ IIhsm $ & & II)#. / IIil3&7> ?rcj|j|\}}t|\}}|j|yrn)r3rra)rr%rrr+s r packet_HANDLEz FileTransferClient.packet_HANDLE\s/$$T*4$K  6rcf|j|\}}|jt|dyr)r3rarrr%rs r packet_DATAzFileTransferClient.packet_DATAas*$$T*4 5;q>"rc:|j|\}}tjd|dd\}|dd}g}t|D]F}t |\}}t |\}}|j |\}}|j |||fH|j|yr1)r3r!r.rKrrSrVra) rr%rcountfilesrPrrrMs r packet_NAMEzFileTransferClient.packet_NAMEes$$T*4==tBQx0ABxu 6A"4[NHd"4[NHd//5KE4 LL(He4 5  6 5rcr|j|\}}|j|j|dyr)r3rarSrfs r packet_ATTRSzFileTransferClient.packet_ATTRSqs2$$T*4 4((.q12rcN|j|\}}|j|yrn)r3rarfs rpacket_EXTENDED_REPLYz(FileTransferClient.packet_EXTENDED_REPLYus"$$T*4 4rcy)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 serverVersionr[s rr^z#FileTransferClient.gotServerVersionysrNr)rcrdrerr#r_r/r3rr6rrrrrrrrrrrRrr_rbrdrgrkrmror^rrrrrs!( 1*( D" ; H T 6 D.& 4 / M / C *@, # 3 rrc0eZdZdZdZdZdZdZdZy)r7c2||_t||_yrn)parentrrrrtrs rrzClientFile.__init__s j rcV|jjt|jSrn)rtr/ FXP_CLOSErrs rrzClientFile.close{{'' 4;;??rc|jtjd||z}|jj t |S)Nr)rr!r"rtr/FXP_READ)rrr7r%s rrzClientFile.readChunks4{{V[[??{{''$77rc|jtjd|zt|z}|jj t |S)Nr<)rr!r"rrtr/ FXP_WRITE)rrchunkr%s rrzClientFile.writeChunks;{{V[[v66EB{{'' 488rcV|jjt|jSrn)rtr/ FXP_FSTATrrs rrzClientFile.getAttrsrxrc|j|jj|z}|jjt|Srn)rrtr\r/r)rrMr%s rrzClientFile.setAttrss6{{T[[88??{{'' 488rN) rcrdrerrrrrrrrrr7r7s"!@89@9rr7c:eZdZdZdZdZdZdZeZdZ dZ y) rHc@||_t||_g|_yrn)rtrr filesCacherus rrzClientDirectory.__init__s j rcV|jjt|jSrn)rtr/ FXP_READDIRrrs rreadzClientDirectory.reads{{'' T[[AArc|jtjdS|jj t |j}d|_|Srn)rr succeedrtr/rwrrs rrzClientDirectory.closesA ;; ==& & KK $ $Y < rc|Srnrrs r__iter__zClientDirectory.__iter__s rc$tjdtd|jr|jj dS|j t |j }|j|j|j|S)NzeUsing twisted.conch.ssh.filetransfer.ClientDirectory as an iterator was deprecated in Twisted 18.9.0.)category stacklevelr) warningsrDeprecationWarningrpoprr addCallbacks _cbReadDir _ebReadDirrs r__next__zClientDirectory.__next__sr C(   ????&&q) ) ?? "/ ! IIK t8rc |dd|_|dS)Nrr)r)rnamess rrzClientDirectory._cbReadDirs)Qxrct|jtd|_tjt Srn)traprrr rr)rras rrzClientDirectory._ebReadDirs& H}//rN) rcrdrerrrrrrrrrrrrHrHs- B" D0rrHc0eZdZddZedZdefdZy)rcXtj|||_||_||_yrn)r5rr_messager)r errorCode errorMessagers rrzSFTPError.__init__s%4  $  rc|jS)zX A string received over the network that explains the error to a human. )rrs rrzSFTPError.messages}}rreturnc:d|jd|jS)Nz SFTPError z: )rrrs r__str__zSFTPError.__str__sDII;b77rN))rcrdrerpropertyrrhrrrrrrs'   88rrrrrr)r*r=r( r efghil @FXP_)brrr!rtypingrzope.interfacertwisted.conch.interfacesrrtwisted.conch.ssh.commonrrtwisted.internetr r r twisted.loggerr twisted.pythonr twisted.python.compatrrProtocolrrlrr7rHr5rr"rzr5rwrzr|rLrrO FXP_FSETSTATrGrr=rCrErWrKr?rQrUrrrrrr[rrFFILEXFER_ATTR_UIDGIDrGrHrIrJFILEXFER_TYPE_REGULARFILEXFER_TYPE_DIRECTORYFILEXFER_TYPE_SYMLINKFILEXFER_TYPE_SPECIALFILEXFER_TYPE_UNKNOWNFXF_READ FXF_WRITE FXF_APPEND FXF_CREAT FXF_TRUNCFXF_EXCLFXF_TEXTrrr r rFX_BAD_MESSAGEFX_NO_CONNECTIONFX_CONNECTION_LOSTr4rFX_NOT_A_DIRECTORYFX_FILE_IS_A_DIRECTORYglobalsgrvkeysr9rUr rrrrrs# &;.33!"=Ix((IXn)nb m )m `  Y9990-0-0`8 8.                      !/&$#             # I N7D v$.212h$$U+7tUr