+
    Dfj                        ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
 ^ RIHtHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ R	IHtHt  ! R
 R]P2                  4      t ! R R]4      t ! R R]4      t]! ]	4       ! R R4      4       t ! R R4      t ! R R]4      t ^t!^t"^t#^t$^t%^t&^t'^t(^	t)^
t*^t+^t,^t-^t.^t/^t0^t1^t2^t3^t4^et5^ft6^gt7^ht8^it9^t:^t;^t<^t=]=t>^t?^t@RtA^tB^tC^tD^tE^tF^tG^tH^tI^tJ^tK^ tL^@tM^ tN^tO^tP^tQ^tR^tS^tT^tU^tV^tW]RtX]RtY]Z! 4       t[]\! ][P                  4       4       F;  t^]^P                  R4      '       g   K  ][]^,          t`]^R,          ]P                  ]`&   K=  	  A[A^A`R# )    N)Dict)implementer)	ISFTPFileISFTPServer)NSgetNS)defererrorprotocol)Logger)failure)nativeStringnetworkStringc                   r   a a ] tR t^t o]! 4       tR	t/ tR tR t	R t
R tR tV 3R ltV3R ltRtVtV ;t# )
FileTransferBasec                "    R V n         RV n        R#     N)bufotherVersionselfs   &@/usr/lib/python3/dist-packages/twisted/conch/ssh/filetransfer.py__init__FileTransferBase.__init__   s     r   c                    V P                   P                  \        P                  ! R \	        V4      ^,           V4      V,           4       R# )z!LBN)	transportwritestructpacklen)r   kinddatas   &&&r   
sendPacketFileTransferBase.sendPacket"   s.    V[[D	AtDtKLr   c                ^   V ;P                   V,          un         \        V P                   4      ^	8  EdI   V P                   R,          p\        P                  ! RV4      w  r4p\        V P                   4      ^V,           8  d   R# V P                   ^^V,            V P                   ^V,           R uqn         V P                  P                  VR4      pV'       g    V P                  P                  RVR7       K  \        V RV 2R4      pV'       gC   V P                  P                  RVVR,          R	7       V P                  V\        R
V 24       EK9  V P                  P                  RVVR7        V! V4       EKc  R#   \         d#    T P                  P                  RTR7        EK  i ; i)	   :Nr'   Nz!LBLNzno packet type for {kind})r"   packet_z+not implemented: {packetType} data={data!r}   NN)
packetTyper#   zdon't understand z+dispatching: {packetType} requestId={reqId})r+   reqIdz,Failed to handle packet of type {packetType})r+   )r   r!   r   unpackpacketTypesget_loginfogetattr_sendStatusFX_OP_UNSUPPORTED	Exceptionr   )r   r#   headerlengthr"   r,   r+   fs   &&      r   dataReceivedFileTransferBase.dataReceived%   s~   D $((mq XXb\F"(--"?F% 488}q6z) "XXa!f*5txxF
7MND())--dD9J		:F
|4d;A		A)b  
   ,0A*.N IINN=%  
$W !X  		!!B) "  s   2E? ?(F,+F,c                |   \         P                  ! R VR,          4      w  p/ pVR,          pV\        ,          \        8X  d.   \         P                  ! RVR,          4      w  pWCR&   VR,          pV\        ,          \        8X  d2   \         P                  ! RVR,          4      w  rVWSR&   WcR	&   VR,          pV\        ,          \        8X  d.   \         P                  ! R VR,          4      w  pWsR
&   VR,          pV\
        ,          \
        8X  d2   \         P                  ! RVR,          4      w  rWR&   WR&   VR,          pV\        ,          \        8X  df   \         P                  ! R VR,          4      w  p
VR,          p\        V
4       F-  p\        V4      w  r\        V4      w  rWR\        V4       2&   K/  	  W13# )!LNr*   Nr)   !QN   Nsizer@   NN!2Luidgidpermissionsatimemtimeext_)
r   r-   FILEXFER_ATTR_SIZEFILEXFER_ATTR_OWNERGROUPFILEXFER_ATTR_PERMISSIONSFILEXFER_ATTR_ACMODTIMEFILEXFER_ATTR_EXTENDEDranger   r   )r   r#   flagsattrsrA   rD   rE   permsrG   rH   extendedCountiextendedTypeextendedDatas   &&            r   _parseAttributes!FileTransferBase._parseAttributes`   s~   ==tBx0Bx%%);;mmD$r(3GT &M8D++/GG}}UDH5HC%L%L8D,,0II}}T484HU#(- 8D**.EE!==R9LE"'N"'N8D))-CC%}}T48<]8D=)',T{$',T{$=I\,789: * {r   c                   ^ pRpRV9   d3   V\         P                  ! RVR,          4      ,          pV\        ,          pRV9   dB   RV9   d;   V\         P                  ! RVR,          VR,          4      ,          pV\        ,          pRV9   d3   V\         P                  ! RVR,          4      ,          pV\        ,          pR	V9   dB   R
V9   d;   V\         P                  ! RVR	,          VR
,          4      ,          pV\
        ,          p. pV F_  pVP                  R4      '       g   K  \        \        VR,          4      4      p\        W,          4      pVP                  Wg,           4       Ka  	  V'       dM   V\         P                  ! R\        V4      4      ,          pVRP                  V4      ,          pV\        ,          p\         P                  ! RV4      V,           # )r   r   rA   r>   rD   rE   rC   rF   r<   rG   rH   rI   r)   )r   r    rJ   rK   rL   rM   
startswithr   r   appendr!   joinrN   )r   rQ   rP   r#   extendedkextTypeextDatas   &&      r   _packAttributes FileTransferBase._packAttributes   sq   U?FKKeFm44D''EE>eunFKKuU|U5\BBD--EE!FKKeM&:;;D..Ee5 0FKKuW~uW~FFD,,EA||F##]1R512UX, 12	 
 FKKc(m44DCHHX&&D++E{{4'$..r   c                4   < \         SV `  V4       RV n        R# )z:
Called when connection to the remote subsystem was lost.
FN)superconnectionLost	connected)r   reason	__class__s   &&r   re   FileTransferBase.connectionLost   s    
 	v&r   c                <   < V ^8  d   Qh/ S[ S[S[3,          ;R&   # )   r.   )r   intstr)format__classdict__s   "r   __annotate__FileTransferBase.__annotate__   s     
 c3h$ r   )r   rf   r   )   )__name__
__module____qualname____firstlineno__r   r0   versionsr.   r   r$   r9   rW   ra   re   __annotate_func____static_attributes____classdictcell____classcell__)rh   ro   s   @@r   r   r      s>     8DH"$K!M9v>/6G  r   r   c                   
  a  ] tR t^t o R&R ltR tR tR tR tR'R lt	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR(R ltR tR tR tR tR tR tR tR tR t R t!R  t"R)R! lt#R*R" lt$R+R# lt%R$ t&R%t'V t(R# ),FileTransferServerNc                l    \         P                  V 4       \        V4      V n        / V n        / V n        R # N)r   r   r   client	openFilesopenDirs)r   r#   avatars   &&&r   r   FileTransferServer.__init__   s*    !!$'!&)r   c                *   \         P                  ! R VR,          4      w  p\        \        V P                  4      V.,           4      V n        VR,          p/ pV'       d!   \        V4      w  rA\        V4      w  rQWSV&   K(  V P                  P                  W#4      pRpVP                  4        F'  w  rV\        V4      \        V	4      ,           ,          pK)  	  V P                  \        \         P                  ! R V P
                  4      V,           4       R# r<   r=   r)   r   N)r   r-   minlistrw   versionr   r   
gotVersionitemsr   r$   FXP_VERSIONr    )
r   r#   r   extextNamer`   ourExt
ourExtDatar^   vs
   &&        r   packet_INITFileTransferServer.packet_INIT   s    ]]4b2
4.':;Bx!$KMG!$KMG"L''5
LLNDA"Q%"Q%-'J #V[[t||%Dz%QRr   c                   VR ,          pVR,          p\        V4      w  r1\        P                  ! RVR ,          4      w  pVR,          pV P                  V4      w  rQVR8X  g   Q RV: 24       h\        P
                  ! V P                  P                  W4V4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r<   r   zstill have data in OPEN: s   open failedN)r   r   r-   rW   r	   maybeDeferredr   openFileaddCallback_cbOpenFile
addErrback	_ebStatus)r   r#   	requestIdfilenamerP   rQ   ds   &&     r   packet_OPENFileTransferServer.packet_OPEN   s    H	Bxt==tBx0Bx++D1s{@7x@@{ 4 4huM	d&&	2	T^^Y?r   c                    \        \        \        V4      4      4      pW0P                  9   d   \	        R 4      hWP                  V&   V P                  \        V\        V4      ,           4       R# )zid already openN)r   rm   hashr   KeyErrorr$   
FXP_HANDLEr   )r   fileObjr   fileIds   &&& r   r   FileTransferServer._cbOpenFile   sN    s4=12^^#,--!(v
I6
$:;r   c                Z   VR ,          pVR,          p\        V4      w  r1V P                  P                  RVVR7       VR8X  g   Q RV: 24       hW0P                  9   do   V P                  V,          p\        P
                  ! VP                  4      pVP                  V P                  W24       VP                  V P                  VR4       R# W0P                  9   dw   V P                  V,          ^ ,          p\        P
                  ! VP                  4      pVP                  V P                  W2^4       VP                  V P                  VR4       R# \        P                  p\        P                  ! V4      p\!        Wx4      p	V P                  \"        P$                  ! V	4      V4       R# )r=   r)   z!closing: {requestId!r} {handle!r})r   handler   zstill have data in CLOSE: s   close failedN)r   r0   r1   r   r	   r   closer   _cbCloser   r   r   errnoENOENTosstrerrorOSErrorr   Failure)
r   r#   r   r   r   r   dirObjcodetexterrs
   &&        r   packet_CLOSEFileTransferServer.packet_CLOSE   s;   H	BxT{		/ 	 	

 s{A8AA{^^#nnV,G##GMM2AMM$--;LLOD}}$]]6*1-F##FLL1AMM$--A>LLOD<<D;;t$D$%CNN7??3/;r   c                z    V'       d   V P                   V MV P                  V V P                  V\        R 4       R# )s   file closedN)r   r   r3   FX_OK)r   resultr   r   isDirs   &&&&&r   r   FileTransferServer._cbClose   s/    f%v&E>:r   c                   VR ,          pVR,          p\        V4      w  r1\        P                  ! RVR,          4      VR,          uw  rEpVR8X  g   Q RV: 24       hW0P                  9  d1   V P	                  \
        P                  ! \        4       4      V4       R# V P                  V,          p\        P                  ! VP                  WE4      pVP                  V P                  V4       VP                  V P                  VR4       R# )	r=   r)   !QL:N   N:r   NNr   zstill have data in READ: s   read failedN)r   r   r-   r   _ebReadr   r   r   r	   r   	readChunkr   _cbReadr   r   )r   r#   r   r   offsetr7   r   r   s   &&      r   packet_READFileTransferServer.packet_READ   s    H	BxT{!'ud3i!@$s)$s{@7x@@{'LL4i@nnV,G##G$5$5vFAMM$,,	2LLNCr   c                t    VR 8X  d   \        4       hV P                  \        V\        V4      ,           4       R# r   )EOFErrorr$   FXP_DATAr   r   r   r   s   &&&r   r   FileTransferServer._cbRead   s(    S=*)bj"89r   c                0   VR ,          pVR,          p\        V4      w  r1\        P                  ! RVR,          4      w  pVR,          p\        V4      w  rQVR8X  g   Q RV: 24       hW0P                  9  d1   V P	                  \
        P                  ! \        4       4      V4       R	# V P                  V,          p\        P                  ! VP                  WE4      pVP                  V P                  VR4       VP                  V P                  VR4       R	# )
r=   r)   r>   r?   rB   r   zstill have data in WRITE: s   write succeededs   write failedN)r   r   r-   r   _ebWriter   r   r   r	   r   
writeChunkr   	_cbStatusr   r   )r   r#   r   r   r   	writeDatar   r   s   &&      r   packet_WRITEFileTransferServer.packet_WRITE   s    H	BxT{MM$R1	Bx+	s{A8AA{'MM'//(*5yAnnV,G##G$6$6JAMM$..)5GHLLODr   c                2   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       h\        P                  ! V P                  P                  V4      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in REMOVE: s   remove succeededs   remove failedN)	r   r	   r   r   
removeFiler   r   r   r   )r   r#   r   r   r   s   &&   r   packet_REMOVE FileTransferServer.packet_REMOVE  s~    H	Bxts{B9$BB{ 6 6A	dnni1DE	T^^Y0@Ar   c                L   VR ,          pVR,          p\        V4      w  r1\        V4      w  rAVR8X  g   Q RV: 24       h\        P                  ! V P                  P                  W44      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in RENAME: s   rename succeededs   rename failedN)	r   r	   r   r   
renameFiler   r   r   r   )r   r#   r   oldPathnewPathr   s   &&    r   packet_RENAME FileTransferServer.packet_RENAME  s    H	Bxdds{B9$BB{ 6 6I	dnni1DE	T^^Y0@Ar   c                X   VR ,          pVR,          p\        V4      w  r1V P                  V4      w  rAVR8X  g   Q RV: 24       h\        P                  ! V P                  P
                  W44      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in MKDIR: s   mkdir succeededs   mkdir failedN)
r   rW   r	   r   r   makeDirectoryr   r   r   r   r   r#   r   pathrQ   r   s   &&    r   packet_MKDIRFileTransferServer.packet_MKDIR#  s    H	Bx4[
++D1s{A8AA{ 9 94G	dnni1CD	T^^Y@r   c                2   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       h\        P                  ! V P                  P                  V4      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in RMDIR: s   rmdir succeededs   rmdir failedN)	r   r	   r   r   removeDirectoryr   r   r   r   r   r#   r   r   r   s   &&   r   packet_RMDIRFileTransferServer.packet_RMDIR-  s}    H	Bx4[
s{A8AA{ ; ;TB	dnni1CD	T^^Y@r   c                0   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       h\        P                  ! V P                  P                  V4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in OPENDIR: s   opendir failedN)	r   r	   r   r   openDirectoryr   _cbOpenDirectoryr   r   r   s   &&   r   packet_OPENDIR!FileTransferServer.packet_OPENDIR6  s}    H	Bx4[
s{C:4(CC{ 9 94@	d++Y7	T^^Y0ABr   c                    \        \        \        V4      4      4      pW0P                  9   d   \	        R 4      hV\        V4      .V P                  V&   V P                  \        V\        V4      ,           4       R# )zalready opened this directoryN)	r   rm   r   r   r   iterr$   r   r   )r   r   r   r   s   &&& r   r   #FileTransferServer._cbOpenDirectory?  sY    s4<01]]":;;!'f 6f
I6
$:;r   c                   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       hW0P                  9  d1   V P                  \        P                  ! \        4       4      V4       R# V P                  V,          w  rE\        P                  ! V P                  V. 4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in READDIR: s   scan directory failedN)r   r   r   r   r   r   r	   r   _scanDirectoryr   _cbSendDirectoryr   )r   r#   r   r   r   dirIterr   s   &&     r   packet_READDIR!FileTransferServer.packet_READDIRF  s    H	BxT{s{C:4(CC{&NN7??8:6	B"mmF3OF##D$7$7"EAMM$//;LL4LMr   c                "   \        V4      ^8  d^    \        V4      p\	        T\
        P                  4      '       d   TP                  T P                  Y4       R# TP                  T4       Km  V#   \         d    T'       g   \        hTu # i ; i)   N)
r!   nextStopIterationr   
isinstancer	   Deferredr   _cbScanDirectoryr[   )r   r   r8   r1   s   &&& r   r   !FileTransferServer._scanDirectoryS  su    !fslG}
 $//  !6!6C ! "Ns   A0 0BBBc                F    VP                  V4       V P                  W#4      # r   )r[   r   )r   r   r   r8   s   &&&&r   r   #FileTransferServer._cbScanDirectoryb  s    	""7..r   c           
        R pV FA  w  rEpV\        V4      ,          pV\        V4      ,          pW0P                  V4      ,          pKC  	  V P                  \        V\        P
                  ! R\        V4      4      ,           V,           4       R# )r   r<   N)r   ra   r$   FXP_NAMEr   r    r!   )r   r   r   r#   r   longnamerQ   s   &&&    r   r   #FileTransferServer._cbSendDirectoryf  sn    )/%HBxL DBxL D((//D *0 	)fkk$F.L"Lt"STr   c                0   VR ,          pVR,          p\        V4      w  rAVR8X  g   Q RV: 24       h\        P                  ! V P                  P                  WB4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in STAT/LSTAT: s   stat/lstat failedN)	r   r	   r   r   getAttrsr   _cbStatr   r   )r   r#   followLinksr   r   r   s   &&&   r   packet_STATFileTransferServer.packet_STATn  s{    H	Bx4[
s{F=dXFF{ 4 4dH	dllI.	T^^Y0DEr   c                *    V P                  V^ 4       R# r   N)r  )r   r#   s   &&r   packet_LSTATFileTransferServer.packet_LSTATw  s    q!r   c                   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       hW0P                  9  d5   V P                  \        P                  ! \        V R24      4      V4       R# V P                  V,          p\        P                  ! VP                  4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in FSTAT: z not in self.openFiless   fstat failedN)r   r   r   r   r   r   r	   r   r  r   r  r   )r   r#   r   r   r   r   s   &&    r   packet_FSTATFileTransferServer.packet_FSTATz  s    H	BxT{s{A8AA{'NNF83I)J KL
 nnV,G##G$4$45AMM$,,	2LLODr   c                `    W P                  V4      ,           pV P                  \        V4       R # r   )ra   r$   	FXP_ATTRS)r   r   r   r#   s   &&& r   r  FileTransferServer._cbStat  s#    //77	4(r   c                |   VR ,          pVR,          p\        V4      w  r1V P                  V4      w  rAVR8w  d   V P                  P                  RVR7       \        P
                  ! V P                  P                  W44      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   r   z$Still have data in SETSTAT: {data!r})r#   s   setstat succeededs   setstat failedN)r   rW   r0   warnr	   r   r   setAttrsr   r   r   r   r   s   &&    r   packet_SETSTAT!FileTransferServer.packet_SETSTAT  s    H	Bx4[
++D13;IINNANM 4 4dB	dnni1EF	T^^Y0ABr   c                   VR ,          pVR,          p\        V4      w  r1V P                  V4      w  rAVR8X  g   Q RV: 24       hW0P                  9  d1   V P                  \        P
                  ! \        4       4      V4       R# V P                  V,          p\        P                  ! VP                  V4      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in FSETSTAT: s   fsetstat succeededs   fsetstat failedN)r   rW   r   r   r   r   r   r	   r   r  r   r   r   )r   r#   r   r   rQ   r   r   s   &&     r   packet_FSETSTAT"FileTransferServer.packet_FSETSTAT  s    H	BxT{++D1s{D;D8DD{'NN7??8:6	BnnV,G##G$4$4e<AMM$..)5JKLL4FGr   c                0   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       h\        P                  ! V P                  P                  V4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in READLINK: s   readlink failedN)	r   r	   r   r   readLinkr   _cbReadLinkr   r   r   s   &&   r   packet_READLINK"FileTransferServer.packet_READLINK  }    H	Bx4[
s{D;D8DD{ 4 4d;	d&&	2	T^^Y0BCr   c                2    V P                  VR / 3.V4       R# r   )r   r   s   &&&r   r  FileTransferServer._cbReadLink  s    R019=r   c                (   VR ,          pVR,          p\        V4      w  r1\        V4      w  rA\        P                  ! V P                  P                  W44      pVP                  V P                  VR4       VP                  V P                  VR4       R# )r=   r)   s   symlink succeededs   symlink failedN)	r   r	   r   r   makeLinkr   r   r   r   )r   r#   r   linkPath
targetPathr   s   &&    r   packet_SYMLINK!FileTransferServer.packet_SYMLINK  sq    H	Bxt ;
 4 4hK	dnni1EF	T^^Y0ABr   c                0   VR ,          pVR,          p\        V4      w  r1VR8X  g   Q RV: 24       h\        P                  ! V P                  P                  V4      pVP                  V P                  V4       VP                  V P                  VR4       R# )r=   r)   r   zstill have data in REALPATH: s   realpath failedN)	r   r	   r   r   realPathr   r  r   r   r   s   &&   r   packet_REALPATH"FileTransferServer.packet_REALPATH  r  r   c                (   VR ,          pVR,          p\        V4      w  r4\        P                  ! V P                  P                  W44      pVP                  V P                  V4       VP                  V P                  VRV,           R,           4       R# )r=   r)   s	   extended s    failedN)	r   r	   r   r   extendedRequestr   _cbExtendedr   r   )r   r#   r   r   r`   r   s   &&    r   packet_EXTENDED"FileTransferServer.packet_EXTENDED  sn    H	Bx ; ; ;WN	d&&	2	T^^Yw0F0STr   c                >    V P                  \        W!,           4       R # r   )r$   FXP_EXTENDED_REPLY)r   r#   r   s   &&&r   r.  FileTransferServer._cbExtended  s    *I,<=r   c                4    V P                  V\        V4       R # r   )r3   r   )r   r   r   msgs   &&&&r   r   FileTransferServer._cbStatus  s    E3/r   c                   \         pTp\        VP                  \        \        34      '       d   VP                  P
                  \
        P                  8X  d(   \        p\        VP                  P                  4      pEMVP                  P
                  \
        P                  8X  d(   \        p\        VP                  P                  4      pEMVP                  P
                  \
        P                  8X  d	   \        pEMhV P                  P                  R VVVR7       EMG\        VP                  \         4      '       dJ   \"        pVP                  P$                  '       d'   \        VP                  P$                  ^ ,          4      pM\        VP                  \&        4      '       dJ   \(        pVP                  P$                  '       d'   \        VP                  P$                  ^ ,          4      pMu\        VP                  \*        4      '       d7   VP                  P,                  p\        VP                  P.                  4      pMV P                  P                  RVVVR7       V P1                  W$V4       R# )z%Request {requestId} failed: {message})r   r   messagez8Request {requestId} failed with unknown error: {message}N)
FX_FAILUREr   valueIOErrorr   r   r   FX_NO_SUCH_FILEr   r   EACCESFX_PERMISSION_DENIEDEEXISTFX_FILE_ALREADY_EXISTSr0   r   r   FX_EOFargsNotImplementedErrorr4   	SFTPErrorr   r8  r3   )r   rg   r   r5  r   r8  s   &&&&  r   r   FileTransferServer._ebStatus  s   fllWg$677||!!U\\1&'(=(=>##u||3+'(=(=>##u||3-		!!;"'#	 "  h//D||   '(9(9!(<=&9::$D||   '(9(9!(<=i00<<$$D#FLL$8$89GIIJ#	   	'2r   c                    V\         P                  ! RV4      ,           pV\        V4      ,          pV\        V4      ,          pV P                  \        V4       R# )z-
Helper method to send a FXP_STATUS message.
r<   N)r   r    r   r$   
FXP_STATUS)r   r   r   r8  langr#   s   &&&&& r   r3   FileTransferServer._sendStatus  sC     6;;tT2274
D)r   c                   \         P                  W4       V P                  P                  4        F  pVP	                  4        K  	  / V n        V P
                  P                  4        F  w  r4VP	                  4        K  	  / V n        R# )zc
Called when connection to the remote subsystem was lost.

Clean all opened files and directories.
N)r   re   r   valuesr   r   )r   rg   r   r   r   s   &&   r   re   !FileTransferServer.connectionLost  sb     	''5~~,,.GMMO /#}}335OFLLN  6r   )r   r   r   r   )NNr   )   )s   request succeeded)s   request failed)r   ))rs   rt   ru   rv   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.  r   r   r3   re   ry   rz   ro   s   @r   r}   r}      s     S
@<<4;D:
E BBAAC<N/UF"E )	CHD>CDU>0%3N* r   r}   c                      a  ] tR tRt o / 3R ltR tR tR tR tR t	R t
R	 tR
 tR tR tR tRR ltR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV t R# ) FileTransferClienti  c                Z    \         P                  V 4       / V n        ^ V n        / V n        R# )zY
@param extData: a dict of extended_name : extended_data items
to be sent to the server.
N)r   r   r`   counteropenRequests)r   r`   s   &&r   r   FileTransferClient.__init__  s(    
 	!!$'r   c                   \         P                  ! R \        V P                  4      4      pV P                  P                  4        F'  w  r#V\        V4      \        V4      ,           ,          pK)  	  V P                  \        V4       R# )r<   N)	r   r    maxrw   r`   rK  r   r$   FXP_INIT)r   r#   r^   r   s   &   r   connectionMade!FileTransferClient.connectionMade  sX    {{4T]]!34LL'')DABqEBqEM!D *$'r   c                R   \         P                  W4       V P                  '       d   \        P                  ! 4       pVP
                  Vn        \        P                  ! V4      pV P                  '       d0   V P                  P                  4       w  rEVP                  V4       KA  R# R# )z]
Called when connection to the remote subsystem was lost.

Any pending requests are aborted.
N)r   re   rT  r
   ConnectionLostr:  	__cause__r   r   popitemerrback)r   rg   requestErrorrequestFailure_deferreds   &&    r   re   !FileTransferClient.connectionLost%  s     	''5  !//1L%+\\L"$__\:N###"//779  0 $ r   c                z   V P                   '       g*   \        P                  ! \        P                  ! 4       4      # \
        P                  ! RV P                  4      V,           p\        P                  ! 4       pW0P                  V P                  &   V ;P                  ^,          un        V P                  W4       V# )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<   )rf   r	   failr
   r\  r   r    rS  r   rT  r$   )r   r5  r#   r   s   &&& r   _sendRequestFileTransferClient._sendRequest:  s{     ~~~::e22455{{4.5NN*+$,,'"r   c                    \         P                  ! R VR,          4      w  pV P                  V,          pV P                  V W1R,          3# )r<   r=   r)   )r   r-   rT  )r   r#   idr   s   &&  r   _parseRequest FileTransferClient._parseRequestN  sB    dDH-b!b!r({r   c                    \        V4      \        P                  ! RV4      ,           V P                  V4      ,           pV P	                  \
        V4      pVP                  V P                  \        V4       V# )aC  
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<   )	r   r   r    ra   rg  FXP_OPENr   _cbOpenHandle
ClientFile)r   r   rP   rQ   r#   r   s   &&&&  r   r   FileTransferClient.openFileT  sZ    : (|fkk$669M9Me9TTh-	d((*h?r   c                "    V! W4      pW4n         V# )ar  
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)r   r   handleClassrs  cbs   &&&& r   ro   FileTransferClient._cbOpenHandlev  s     &	r   c                @    V P                  \        \        V4      4      # )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.
)rg  
FXP_REMOVEr   )r   r   s   &&r   r   FileTransferClient.removeFile  s       R\::r   c                `    V P                  \        \        V4      \        V4      ,           4      # )z
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.
)rg  
FXP_RENAMEr   )r   oldpathnewpaths   &&&r   r   FileTransferClient.renameFile  s$       R[2g;-FGGr   c                l    V P                  \        \        V4      V P                  V4      ,           4      # )a5  
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.
)rg  	FXP_MKDIRr   ra   )r   r   rQ   s   &&&r   r    FileTransferClient.makeDirectory  s+       BtHt7K7KE7R,RSSr   c                @    V P                  \        \        V4      4      # )z
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.
)rg  	FXP_RMDIRr   )r   r   s   &&r   r   "FileTransferClient.removeDirectory  s       BtH55r   c                    V P                  \        \        V4      4      pVP                  V P                  \
        V4       V# )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.
)rg  FXP_OPENDIRr   r   ro  ClientDirectoryr   r   r   s   && r   r    FileTransferClient.openDirectory  s5    < k2d84	d((/4@r   c                b    V'       d   \         pM\        pV P                  V\        V4      4      # )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_LSTATrg  r   )r   r   r  ms   &&& r   r  FileTransferClient.getAttrs  s(     AA  BtH--r   c                p    \        V4      V P                  V4      ,           pV P                  \        V4      # )a$  
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.
)r   ra   rg  FXP_SETSTAT)r   r   rQ   r#   s   &&& r   r  FileTransferClient.setAttrs  s0     $x$..u55  d33r   c                v    V P                  \        \        V4      4      pVP                  V P                  4      # )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.
)rg  FXP_READLINKr   r   _cbRealPathr  s   && r   r  FileTransferClient.readLink   /     lBtH5}}T--..r   c                `    V P                  \        \        V4      \        V4      ,           4      # )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.
)rg  FXP_SYMLINKr   )r   r$  r%  s   &&&r   r#  FileTransferClient.makeLink  s$       blR
^.KLLr   c                v    V P                  \        \        V4      4      pVP                  V P                  4      # )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.
)rg  FXP_REALPATHr   r   r  r  s   && r   r)  FileTransferClient.realPath  r  r   c                @    V^ ,          w  r#pVP                  R4      pV# )r   zutf-8)decode)r   r   rs  r   rQ   s   &&   r   r  FileTransferClient._cbRealPath(  s#     &q	{{7#r   c                N    V P                  \        \        V4      V,           4      # )a+  
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.
)rg  FXP_EXTENDEDr   )r   requestr#   s   &&&r   r-  "FileTransferClient.extendedRequest-  s        r'{T/ABBr   c                    \         P                  ! R VR,          4      w  pVR,          p/ pV'       d!   \        V4      w  rA\        V4      w  rQWSV&   K(  W n        V P	                  W#4       R# r<   r=   r)   N)r   r-   r   r   gotServerVersion)r   r#   r   r   r^   r   s   &&    r   packet_VERSION!FileTransferClient.packet_VERSION;  sY    ]]4b2
BxDkGADkGAaDg)r   c                &   V P                  V4      w  r!\        P                  ! R VR,          4      w  pVR,          p\        V4      ^8  d/   \	        V4      w  rA\        V4      ^8  d   \	        V4      w  rQMRpMRpRpV\
        8X  d   VP                  WE34       R# V\        8X  d   VP                  \        V4      4       R# V\        8X  d   VP                  \        V4      4       R# VP                  \        V\        V4      V4      4       R# r   )rk  r   r-   r!   r   r   callbackrA  r_  r   r4   rC  rD  r   )r   r#   r   r   r5  rH  s   &&    r   packet_STATUS FileTransferClient.packet_STATUSF  s    $$T*--d2h/Bxt9>dIC4yA~"4[
dCD5=JJ{#V^IIhsm$&&II)#./IIil3&7>?r   c                h    V P                  V4      w  r!\        V4      w  r4VP                  V4       R # r   )rk  r   r  )r   r#   r   r   rb  s   &&   r   packet_HANDLE FileTransferClient.packet_HANDLE\  s+    $$T*$K		

6r   c                n    V P                  V4      w  r!VP                  \        V4      ^ ,          4       R# r	  )rk  r  r   r   r#   r   s   && r   packet_DATAFileTransferClient.packet_DATAa  s(    $$T*	

5;q>"r   c                H   V P                  V4      w  r!\        P                  ! R VR,          4      w  pVR,          p. p\        V4       FC  p\	        V4      w  ra\	        V4      w  rqV P                  V4      w  rVP                  WgV34       KE  	  VP                  V4       R# r  )rk  r   r-   rO   r   rW   r[   r  )	r   r#   r   countfilesrT   r   r   rQ   s	   &&       r   packet_NAMEFileTransferClient.packet_NAMEe  s    $$T*==tBx0BxuA"4[NH"4[NH//5KELL(e45	 
 	


5r   c                z    V P                  V4      w  r!VP                  V P                  V4      ^ ,          4       R# r	  )rk  r  rW   r  s   && r   packet_ATTRSFileTransferClient.packet_ATTRSq  s0    $$T*	

4((.q12r   c                N    V P                  V4      w  r!VP                  V4       R # r   )rk  r  r  s   && r   packet_EXTENDED_REPLY(FileTransferClient.packet_EXTENDED_REPLYu  s     $$T*	

4r   c                    R# )a  
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.
N )r   serverVersionr`   s   &&&r   r  #FileTransferClient.gotServerVersiony  s    r   )rS  r`   rT  r   NrM  )!rs   rt   ru   rv   r   rY  re   rg  rk  r   ro  r   r   r   r   r   r  r  r  r#  r)  r  r-  r  r  r  r  r  r  r  r  ry   rz   rO  s   @r   rQ  rQ    s     ! (1*( D"	;HT6 D.&4/M/
C	*@,
#
3 r   rQ  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
rp  i  c                2    Wn         \        V4      V n        R # r   )parentr   r   r   r  r   s   &&&r   r   ClientFile.__init__  s    jr   c                V    V P                   P                  \        V P                  4      # r   )r  rg  	FXP_CLOSEr   r   s   &r   r   ClientFile.close      {{''	4;;??r   c                    V P                   \        P                  ! R W4      ,           pV P                  P	                  \
        V4      # )r   )r   r   r    r  rg  FXP_READ)r   r   r7   r#   s   &&& r   r   ClientFile.readChunk  s2    {{V[[??{{''$77r   c                    V P                   \        P                  ! R V4      ,           \        V4      ,           pV P                  P                  \        V4      # )r>   )r   r   r    r   r  rg  	FXP_WRITE)r   r   chunkr#   s   &&& r   r   ClientFile.writeChunk  s;    {{V[[v66EB{{''	488r   c                V    V P                   P                  \        V P                  4      # r   )r  rg  	FXP_FSTATr   r   s   &r   r  ClientFile.getAttrs  r  r   c                    V P                   V P                  P                  V4      ,           pV P                  P                  \        V4      # r   )r   r  ra   rg  r  )r   rQ   r#   s   && r   r  ClientFile.setAttrs  s6    {{T[[88??{{''	488r   )r   r  N)rs   rt   ru   rv   r   r   r   r   r  r  ry   rz   rO  s   @r   rp  rp    s*     !@89@9 9r   rp  c                   N   a  ] tR tRt o R tR tR tR tR t]t	R t
R tR	tV tR
# )r  i  c                @    Wn         \        V4      V n        . V n        R # r   )r  r   r   
filesCacher  s   &&&r   r   ClientDirectory.__init__  s    jr   c                V    V P                   P                  \        V P                  4      # r   )r  rg  FXP_READDIRr   r   s   &r   readClientDirectory.read  s    {{''T[[AAr   c                    V P                   f   \        P                  ! R 4      # V P                  P	                  \
        V P                   4      pR V n         V# r   )r   r	   succeedr  rg  r  r   r   s   & r   r   ClientDirectory.close  sA    ;;==&&KK$$Y<r   c                    V # r   r  r   s   &r   __iter__ClientDirectory.__iter__  s    r   c                6   \         P                  ! R \        ^R7       V P                  '       d   V P                  P	                  ^ 4      # V P                  f   \        4       hV P                  4       pVP                  V P                  V P                  4       V# )zeUsing twisted.conch.ssh.filetransfer.ClientDirectory as an iterator was deprecated in Twisted 18.9.0.)category
stacklevel)
warningsr  DeprecationWarningr  popr   r  addCallbacks
_cbReadDir
_ebReadDirr  s   & r   __next__ClientDirectory.__next__  st    C (	
 ?????&&q))??"/!IIK	t8r   c                0    VR ,          V n         V^ ,          # ):rN  NN)r  )r   namess   &&r   r  ClientDirectory._cbReadDir  s    )Qxr   c                v    VP                  \        4       R V n        \        P                  ! \        4       4      # r   )trapr   r  r   r   r   )r   rg   s   &&r   r  ClientDirectory._ebReadDir  s&    H}//r   )r  r   r  N)rs   rt   ru   rv   r   r  r   r  r  r   r  r  ry   rz   rO  s   @r   r  r    s5     
B" D0 0r   r  c                   L   a  ] tR tRt o RR lt]R 4       tV 3R lR ltRtV t	R# )	rD  i  c                T    \         P                  V 4       Wn        W n        W0n        R # r   )r5   r   r   _messagerH  )r   	errorCodeerrorMessagerH  s   &&&&r   r   SFTPError.__init__  s    4 	$	r   c                    V P                   # )zH
A string received over the network that explains the error to a human.
)r  r   s   &r   r8  SFTPError.message  s     }}r   c                    < V ^8  d   QhRS[ /# )rk   return)rm   )rn   ro   s   "r   rp   SFTPError.__annotate__  s     8 8 8r   c                :    R V P                    RV P                   2# )z
SFTPError z: )r   r8  r   s   &r   __str__SFTPError.__str__  s    DII;b77r   )r  r   rH  N) )
rs   rt   ru   rv   r   propertyr8  r  ry   rz   rO  s   @r   rD  rD    s(      	 	8 8r   rD  l        FXP_r)   )br   r   r   r  typingr   zope.interfacer   twisted.conch.interfacesr   r   twisted.conch.ssh.commonr   r   twisted.internetr	   r
   r   twisted.loggerr   twisted.pythonr   twisted.python.compatr   r   Protocolr   r}   rQ  rp  r  r5   rD  rX  r   rn  r  r  r  r  r  r  FXP_FSETSTATr  r  rx  r  r  r  r  r{  r  r  rG  r   r   r   r  r  r2  rJ   FILEXFER_ATTR_UIDGIDrK   rL   rM   rN   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   rA  r<  r>  r9  FX_BAD_MESSAGEFX_NO_CONNECTIONFX_CONNECTION_LOSTr4   r@  FX_NOT_A_DIRECTORYFX_FILE_IS_A_DIRECTORYglobalsgr   keysrs  rZ   r:  r.   r  r   r   <module>r(     s    	    & ; . 3 3 ! " =Ix(( IXn) nbm) m` Y9 9 90-0 -0`8	 8. 				
		


	  ! / & $ #      	
				
 
    
   #  INDv$.22h$$U+  tUr   