Qf ddlZddlZddlmZgdZdZdZdZGddeZGd d eZ Gd d eZ Gd deZ GddeZ ee efZdZdZGddZ ddlZej(ZGddeZej/dee eej0fZdadZdadZdZdZdZ ddZ!dZ"e#dk(re"yy#e$rdZY1wxYw) N)_GLOBAL_DEFAULT_TIMEOUT)FTP error_reply error_temp error_perm error_proto all_errors c eZdZy)ErrorN__name__ __module__ __qualname__-/opt/alt/python312/lib64/python3.12/ftplib.pyrr9rrc eZdZy)rNrrrrrr:rrrc eZdZy)rNrrrrrr;rrrc eZdZy)rNrrrrrr<rrrc eZdZy)rNrrrrrr=rrr s cVeZdZ dZdZeZeZdZ dZ dZ dZ dZ ddddedfdddZd Zd Zd1d Zd Zd ZeZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d2dZ%d2dZ&d3dZ'd4d Z(d2d!Z)d5d"Z*d2d#Z+d$Z,d%Z-d&Z.dgfd'Z/d(Z0d)Z1d*Z2d+Z3d,Z4d-Z5d.Z6d/Z7d0Z8y)6rrNTFutf-8encodingc ||_||_||_|r(|j||r|j |||yyyN)r source_addresstimeoutconnectlogin)selfhostuserpasswdacctr$r#r s r__init__z FTP.__init__msK ! ,  LL  4. rc|Sr"rr's r __enter__z FTP.__enter__}s rc|j/ |j|j|j yyy#ttf$rY0wxYw#|j|j wwxYwr")sockquitOSErrorEOFErrorclose)r'argss r__exit__z FTP.__exit__sm 99  ! 99(JJL) !X&  99(JJL)s!=A AAAA1cZ |dk7r||_|dkDr||_|dk7r||_|j|js td|||_t j d||j|jtj|j|jf|j|j|_ |jj|_ |jjd|j|_|j|_|j S) Nrrz0Non-blocking socket (timeout=0) is not supportedzftplib.connectr#rr)r(portr$ ValueErrorr#sysauditsocketcreate_connectionr1familyafmakefiler filegetrespwelcome)r'r(r<r$r#s rr%z FTP.connects  2:DI !8DI d?"DL << #DLLOP P  %"0D  "D$))TYY?,,dii-CT\\<@> +t}}T\\: ;||rc ||_yr")rI)r'levels rset_debuglevelzFTP.set_debuglevels H rc ||_yr") passiveserver)r'vals rset_pasvz FTP.set_pasvs 7!rc|dddvr.t|jd}|ddd|dz zz||dz}t|S)N>pass PASS r*)lenrstriprepr)r'sis rrKz FTP.sanitizesP Ra5& &AHHV$%A"1QqS !AabE)AAwrc&d|vsd|vr tdtjd|||tz}|jdkDrt d|j ||jj|j|jy)N  z4an illegal newline character should not be containedzftplib.sendcmdr z*put*) r=r>r?CRLFrIrJrKr1sendallencoder r'lines rputlinez FTP.putliness 4<44<ST T "D$/d{ >>A  '4==. / $++dmm45rct|jrtd|j||j|y)Nz*cmd*)rIrJrKrfrds rputcmdz FTP.putcmds' >>5$--*=> Trc`|jj|jdz}t||jkDrt d|jz|j dkDrt d|j||st|ddtk(r|dd}|S|ddtvr|dd}|S)Nr got more than %d bytesz*get*) rEreadlinemaxlinerYrrIrJrKr4rards rgetlinez FTP.getlinesyy!!$,,"23 t9t|| #04<<?@ @ >>A  '4==. /N 9 9D "#Y$ 9D rc|j}|dddk(r2|dd} |j}|d|zz}|dd|k(r |dddk7r |S,|S)N-r`)ro)r'recodenextlines r getmultilinezFTP.getmultilinesr||~ !9 8D<<>th/BQ<4' 1 ,   rc|j}|jrtd|j||dd|_|dd}|dvr|S|dk(r t ||dk(r t |t|)Nz*resp*rqr >12345)rvrIrJrKlastresprrr)r'respcs rrFz FTP.getresps~  " >> (DMM$/ 0Ra !H  K 8T" " 8T" "$rcN |j}|dddk7r t||S)Nr ry)rFrr'r~s rvoidrespz FTP.voidresps-3||~ 8s?d# # rc dtz}|jdkDrtd|j||jj |t |j}|dddvr t||S)NABORr z *put urgent*rq>225226426) B_CRLFrIrJrKr1rbMSG_OOBrvrr'rer~s rabortz FTP.abortst D >>A  .$--"5 6 $(  " 80 0d# # rcF |j||jSr")rhrFr'cmds rsendcmdz FTP.sendcmds5 C||~rcF |j||jSr")rhrrs rvoidcmdz FTP.voidcmdsF C}}rc |jd}t|dzt|dzg}||z}ddj|z}|j|S)N.zPORT ,)splitr[joinr)r'r(r<hbytespbytesbytesrs rsendportz FTP.sendport sZ CtSy/4S>2'||C  rc  d}|jtjk(rd}|jtjk(rd}|dk(r t ddt ||t |dg}ddj |z}|j|S)Nrr zunsupported address familyrzEPRT |)rCr@AF_INETAF_INET6rr[rr)r'r(r<rCfieldsrs rsendeprtz FTP.sendeprt*sS  77fnn $B 77foo %B 7:; ;d2hd4j"5((||C  rc tjd|jd}|jd}|jjd}|jtj k(r|j ||}n|j||}|jtur|j|j|S)N)rrr )rBbacklogr) r@ create_serverrC getsocknamer1rrrr$r settimeout)r'r1r<r(r~s rmakeportz FTP.makeport7sA##GDGGQG!!$yy$$&q) 77fnn $==t,D==t,D <<6 6 OODLL ) rcR |jtjk(rPt|j d\}}|j r|}||fS|j jd}||fSt|j d|j j\}}||fS)NPASVrEPSV) rCr@rparse227rtrust_server_pasv_ipv4_addressr1 getpeernameparse229)r'untrusted_hostr<r(s rmakepasvz FTP.makepasvDsJ 77fnn $#+DLL,@#A ND22% Tzyy,,.q1Tz"$,,v"6 8M8M8OPJD$Tzrc d}|jr|j\}}tj||f|j|j } ||j d|z|j |}|ddk(r|j}|ddk7r t|n|j5}||j d|z|j |}|ddk(r|j}|ddk7r t||j\}} |jtur|j|jddddddk(r t|}|fS#|jxYw#1swY6xYw)Nr:zREST %srryrxrq150)rQrr@rAr$r#rrFrr5racceptrrparse150) r'rrestsizer(r<connr~r1sockaddrs r ntransfercmdzFTP.ntransfercmdPst    JD$++T4L$,,;?;N;NPD #LLT!12||C(7c><<>D7c>%d++" D#LLT!12||C(7c><<>D7c>%d++!%h<<'>>OODLL1! 8u D>DTz'   sAE'5BE='E:=Fc. |j||dS)Nr)r)r'rrs r transfercmdzFTP.transfercmds>  d+A..rc |sd}|sd}|sd}|dk(r |dvr|dz}|jd|z}|ddk(r|jd|z}|ddk(r|jd |z}|dd k7r t||S) N anonymousr>rrsz anonymous@zUSER rrzrWACCT ryrr)r'r)r*r+r~s rr&z FTP.logins'DFD ; 6Y#6l*F||GdN+ 7c><<& 01D 7c><<$/D 7c>d# # rc\ |jd|j||5}|j|x}r|||j|x}rt t |tr|j ddd|j S#1swY|j SxYwNzTYPE I)rrrecv _SSLSocket isinstanceunwrapr)r'rcallback blocksizerrdatas r retrbinaryzFTP.retrbinarys  X   c4 (D))I..$.))I..$.%*T:*F ) }} ) }}s/B&BB+c |t}|jd}|j|5}|jd|j5} |j |j dz}t||j kDrtd|j z|jdkDrtdt||sn(|ddtk(r|dd}n |d dd k(r|dd }||t t|tr|jdddddd|j!S#1swY!xYw#1swY|j!SxYw) NTYPE Ar;rr rjrz*retr*rkrlr`) print_linerrrDr rmrnrYrrIrJr[rarrrr)r'rrr~rfpres r retrlinesz FTP.retrliness4   !H||H%   c "dsT]];r{{4<>A%(DJ/9$9D"#Y$&9D%*T:*F !<#$}}#<;#$}}s$D; CD/D;/D8 4D;;Ec |jd|j||5}|j|x}r/|j||r|||j|x}r/t t |tr|j ddd|jS#1swY|jSxYwr)rrreadrbrrrr)r'rrrrrrbufs r storbinaryzFTP.storbinarys  X   c4 (D++#+ S!SM++#+ %*T:*F )}})}}sAB&(&B&&B>c" |jd|j|5} |j|jdz}t ||jkDrt d|jz|snA|ddt k7r|dt vr|dd}|t z}|j||r||t t|tr|jddd|jS#1swY|jSxYw)Nrr rjrkrl) rrrmrnrYrrrbrrrr)r'rrrrrs r storlinesz FTP.storliness  X   c "dkk$,,"23s8dll* 84<< GHHrs8v%2w&(CR#,C S!SM%*T:*F # }}!# }}s B:C66Dc0 d|z}|j|S)Nrr)r'passwordrs rr+zFTP.accts$ ||C  rcf d}|D] }|d|zz} g}|j||j|S)NNLST )rappend)r'r6rargfiless rnlstzFTP.nlsts>PCs#C sELL) rc d}d}|ddrt|dts |dd|d}}|D] }|s|d|zz}|j||y)NLISTrlr)rstrr)r'r6rfuncrs rdirzFTP.dir&sh G  9ZR#6crDH$DCS3Y' sD!rc#K |r&|jddj|zdz|rd|z}nd}g}|j||j|D]s}|j t j d\}}}i} |ddjdD]*} | j d\} }} | | | j<,|| fuyw)Nz OPTS MLST ;zMLSD %sMLSDrrl=) rrrrrZra partitionrlower) r'pathfactsrlinesre facts_found_nameentryfactkeyvalues rmlsdzFTP.mlsd5s   LL7#= > d"CC sELL)D#';;t#4#>#>s#C KDE#CR(..s3 $s 3 Q%*ciik"4-  sC C cz |jd|z}|ddk7r t||jd|zS)NzRNFR rrzzRNTO )rrr)r'fromnametonamer~s rrenamez FTP.renameQsB||Gh./ 7c>d# #||Gf,--rcT |jd|z}|dddvr|St|)NzDELE rq>200250r)r'filenamer~s rdeletez FTP.deleteXs6||Gh./ 8~ %Kd# #rc |dk(r |jdS|dk(rd}d|z}|j|S#t$r }|jddddk7rYd}~:d}~wwxYw) Nz..CDUPrrq500rrzCWD )rrr6)r'dirnamemsgrs rcwdzFTP.cwd`sw$ d? ||F++]Gw||C   88A;r?e+, s6 AAAcz |jd|z}|dddk(r|ddj}t|Sy)NzSIZE rq213)rstripint)r'rr~r\s rrzFTP.sizemsF*||Gh./ 8u QR Aq6M rcf |jd|z}|jdsyt|S)NzMKD 257rr startswithparse257)r'rr~s rmkdzFTP.mkdus39||FW,-u%~rc, |jd|zS)NzRMD r)r'rs rrmdzFTP.rmd~s!||FW,--rc` |jd}|jdsyt|S)NPWDr rr rs rpwdzFTP.pwds./||E"u%~rcJ |jd}|j|S)NQUIT)rr5rs rr2zFTP.quits!-||F#  rc |j}d|_||j|j}d|_||jyy#|j}d|_||jwwxYwr")rEr5r1)r'rEr1s rr5z FTP.closesuF 99DDI 99DDI  99DDI  s %A(A7)rrr9Nr")rrr)r N)r NN)9rrrrIr(FTP_PORTr<MAXLINErnr1rErGrQrrr,r/r7r%rLrOdebugrSrKrfrhrorvrFrrrrrrrrrrr&rrrrr+rrrrrrrrrrr2r5rrrrrJs*.I D DG D DGM%*"R0/!/ !4 E!6 $      ! !  5n/4.!F4>!  "" 8.$ !. rrcdeZdZ d dedddfd Zd fd ZdZdZdZd Z dfd Z d Z xZ S)FTP_TLSNr)contextr$r#r c z|tj}||_d|_t ||||||||y)NFr)ssl_create_stdlib_contextr_prot_psuperr,) r'r(r)r*r+rr$r#r __class__s rr,zFTP_TLS.__init__sH446"DL DL G T4$nx  Irc|r4t|jtjs|j t ||||Sr")rr1r SSLSocketauthr!r&)r'r)r*r+securer"s rr&z FTP_TLS.logins3jCMMB 7=vt4 4rc t|jtjr t d|j j tjk\r|jd}n|jd}|j j|j|j|_|jjd|j|_ |S)NzAlready using TLSzAUTH TLSzAUTH SSLserver_hostnamer;)moder )rr1rr$r=rprotocol PROTOCOL_TLSr wrap_socketr(rDr rErs rr%z FTP_TLS.auths D$))S]]3 !455||$$(8(88||J/||J/ 00DII0VDI **dmm*LDIKrc t|jtjs t d|j d}|jj |_|S)Nz not using TLSCCC)rr1rr$r=rrrs rcccz FTP_TLS.cccsI Adii7 11<<&D ((*DIKrcZ |jd|jd}d|_|S)NzPBSZ 0zPROT PTrr rs rprot_pzFTP_TLS.prot_ps- 0 LL "<<)DDLKrc8 |jd}d|_|S)NzPROT CFr2rs rprot_czFTP_TLS.prot_cs 4<<)D DLKrct|||\}}|jr'|jj ||j }||fS)Nr()r!rr rr-r()r'rrrrr"s rrzFTP_TLS.ntransfercmdsL-c48JD$||||//@D 0K: rcdtz}|jj||j}|dddvr t ||S)Nrrq>rrr)rr1rbrvrrs rrz FTP_TLS.abort sKV#D II  d #$$&DBQx44!$''Kr)rrrr)rrrTr") rrrrr,r&r%r0r3r5rr __classcell__)r"s@rrrsC B I $.E$(7 I 5       rrc |dddk7r t|t-ddl}|jd|j|j zatj |}|syt|jdS)Nrqrrz150 .* \((\d+) bytes\)r ) r_150_rerecompile IGNORECASEASCIImatchrgroup)r~r;ms rrrsq BQx5$** %r}}rxx'?A dA  qwwqz?rcJ |dddk7r t|t ddl}|jd|jatj |}|s t ||j}dj|dd}t|ddzt|dz}||fS) Nrq227rz#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)rrrrU) r_227_rer;r<r>searchrgroupsrr)r~r;rAnumbersr(r<s rrr,s5 BQx5$**CRXXNtA $hhjG 88GBQK D  Oq C O 3D :rc |dddk7r t||jd}|dkr t||jd|dz}|dkr t|||dz||dz k7r t|||dz|j||dz}t |dk7r t||d}t |d}||fS)Nrq229(r)r rU)rfindrrrYr)r~peerleftrightpartsr(r<s rrr?s5 BQx5$ 99S>D ax{4(( IIc4!8 $E qy$ D1H~eai($ % & &tDF| 4E 5zQ$ 7D uQx=D :rc |dddk7r t||dddk7ryd}d}t|}||kr/||}|dz}|dk(r||k\s||dk7r |S|dz}||z}||kr/|S)Nrqr rUz "rr ")rrY)r~rr]nrs rr r Ts3 BQx5$ AayDG A D A a% G aC 8AvaC N!AA+ a% Nrc t|yr")rJ)res rrrjs 5 $Krc~ |s|}d|z}|j||j|t|jd\}}|j|||jd|z}|dddvrt|jd|z}|dddvrt|j |j y)NzTYPE rzSTOR rq>125rRETR )rrrrrr) source sourcenametarget targetnametype sourcehost sourceporttreplysreplys rftpcprbos5  T>D NN4 NN4%fnnV&<=J  OOJ +^^Gj0 1F bqz' ^^Gj0 1F bqz' OO OOrcn ttjdkr.ttj tj dddl}d}d}tjddk(r-|dz}tjd=tjddk(r-tjddddk(r'tjddd}tjd=tjd}t|}|j|dx}x}} |j|} |j|\}}}|j|||tjddD]} | ddd k(r|j!| ddn| dddk(r$d } | ddr | d z| ddz} |j#| } n| d k(r|j%|j& n`|j)d| ztj*j,j.dtj*j,j1tj*j1|j3y#ttf$rtdtjYRwxYw#t$r!|td tjYwxYw)Nrrr z-dz-rrz$No account -- using anonymous login.)rEz5Could not open account file -- using anonymous login.z-lCWDrz-prXi)rYr>argvrJtest__doc__exitnetrcrrOauthenticatorsKeyError TypeErrorstderrr3r&rrrSrQrstdoutbufferwriteflushr2) rirIrcfiler(ftpuseridr*r+netrcobjrErr~s rrfrfsW  388}q dll  I F ((1+ aK HHQK ((1+  xx{2A$!QR HHQK 88A;D d)Cy!FVd K;;v&  K#+#:#:4#@ FD&IIffd#  8t  GGDH  "1X CABxsSy483;;s#D T\ LLS... / NN7T>::,,22D : JJ   # # % HHJ%)$ K 8szz J J K #   Izz ##s$ J I*JJ &J43J4__main__)rI)$r>r@r__all__rrr Exceptionrrrrrr3r4r rarrrr$rrrSSLError ImportErrorr:rrErrr rrbrfrrrrr|s!L *    I%% Wh '  R R hu:Jk#kZ NN9(CLL9J $ &*, ,=@ zFK Js%C CC