o b@sdZddlZddlZddlZddlZddlZddlZz ddlZddlZWn e y1dZZYnwddl m Z m Z ddl mZddlmZmZmZmZddlmZmZmZmZmZddlmZmZddlmZmZm Z d Z!d Z"d Z#d Z$d Z%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7d Z8d!Z9d"Z:d#Z;d$Zd'Z?d(Z@d)ZAd*ZBd+ZCd,ZDd-ZEd.ZFd/ZGd0ZHd1ZId2ZJd3ZKd4ZLd5ZMd6ZNd7ZOd8ZPd9ZQd:ZRd;ZSdZVd?ZWd@ZXdAZYdBZZie!dCe"dDe#dEe$dFe%dGe&dHe'dIe(dJe)dKe*dLdMge+dNe,dOe-dPe.dQe0dRe/dSe1dTie2dUe3dVe4dWe5dXe6dYe7dZe8d[e9d\e:d]e;d^edae?dbe@dceAddeBdeieCdfeDdgeEdheFdieGdjeHdkeIdleJdmeKdneLdoeMdpeNdqeOdrePdseQdteRdueSdveTdweVdxeWdyeUdzeXd{eYd|eZd}iZ[Gd~dde\Z]ddZ^ddZ_e`dZadddZbGddde\ZcGdddecZdGdddecZeGdddecZfGdddecZgGdddecZhGdddecZiGdddecZjGdddecZkGdddecZlGdddecZmGddde\ZnGddde\ZoGdddecZpGdddecZqddZrgdZse ejtGdddejuZvGdddejwZxGdddZye ejtGdddZzGdddej{Z|Gdddej{ej}Z~GdddejZGddde ZGddde ZGddde ZddZdddZe eGdd„dƒZe eGddĄdăZGddƄdeZe eGddȄdȃZe ejGddʄdʃZGdd̄deZGdd΄deZGddЄdenZGdd҄denZGddԄdenZGddքdenZGdd؄denZGddڄdڃZGdd܄dejuZGddބdejtZe eGdddejuZddZddZddZGdddejZGdddej{ZGdddejwZGdddeZGdddej{ZddZdS)z An FTP protocol implementation N) Interface implementer) copyright)checkers credentialserrorportal)deferr interfacesprotocolreactor)basicpolicies)failurefilepathlog100120125150z200.1z200.2z200.3202z211.1z211.2212213214215z220.1z220.2z221.1z221.2225z226.1z226.2227229z230.1z230.2250z257.1z257.2z331.1z331.2332350z421.1z421.2425426450451452500501z502.1z502.2503504z530.1z530.2532z550.1z550.2z550.3z550.4z550.5z550.6z550.7551552553z110 MARK yyyy-mmmmz120 service ready in %s minutesz3125 Data connection already open, starting transferz4150 File status okay; about to open data connection.z200 Command OKz200 Type set to %s.z 200 PORT OKz5202 Command not implemented, superfluous at this sitez211 System status replyz 211-Features:z211 Endz212 %sz213 %sz 214 help: %sz215 UNIX Type: L8z220 %sz220 Service readyz&221 Service closing control connectionz 221 Goodbye.z1225 data connection open, no transfer in progressz226 Abort successfulz226 Transfer Complete.z227 Entering Passive Mode (%s).z,229 Entering Extended Passive Mode (|||%s|).z230 User logged in, proceedz2230 Anonymous login ok, access restrictions apply.z&250 Requested File Action Completed OKz257 "%s"z257 "%s" createdz331 Password required for %s.z8331 Guest login ok, type your email address as password.z332 Need account for login.z6350 Requested file action pending further information.z6421 Service not available, closing control connection.z9421 Too many users right now, try again in a few minutes.z425 Can't open data connection.z.426 Transfer aborted. Data connection closed.z/450 Requested action aborted. File unavailable.z8451 Requested action aborted. Local error in processing.z3452 Requested action aborted. Insufficient storage.z500 Syntax error: %sz#501 syntax error in argument(s) %s.z 502 Command '%s' not implementedz 502 Option '%s' not implemented.z&503 Incorrect sequence of commands: %sz'504 Not implemented for parameter '%s'.z$530 Please login with USER and PASS.z!530 Sorry, Authentication failed.z%532 Need an account for storing filesz"550 %s: No such file or directory.z550 %s: Permission denied.z:550 Anonymous users are forbidden to change the filesystemz%550 Cannot rmd, %s is not a directoryz550 %s: File existsz550 %s: is a directoryz"550 Requested action not taken: %sz551 Page type unknownzC552 Requested file action aborted, exceeded file storage allocationz5553 Requested action not taken, file name not allowedc@seZdZdZdS) InvalidPathzL Internal exception used to signify an error during parsing a path. N)__name__ __module__ __qualname____doc__r3r37/usr/lib/python3/dist-packages/twisted/protocols/ftp.pyr.sr.cCs|drg}n|dd}|dD]-}|dks|dkrq|dkr.|r)|qt||d|vs6d|vr;t||||q|S)zn Normalize a path, as represented by a list of strings each representing one segment of the path. /N...) startswithsplitpopr.append)cwdpathsegssr3r3r4 toSegmentss      rBcCs|tjkr tt|S|tjks|tjkrtt|S|tjkr)tt |S|tj kr5tt |S|tj krAtt |StS)z? Map C{OSError} and C{IOError} to standard FTP errors. )errnoENOENTr failFileNotFoundErrorEACCESEPERMPermissionDeniedErrorENOTDIRIsNotADirectoryErrorEEXISTFileExistsErrorEISDIRIsADirectoryError)er?r3r3r4errnoToFailures    rQTESTcCs8|sdS|d}t|}td|d}||krdSdS)a Helper for checking if a FTPShell `segments` contains a wildcard Unix expression. Only filename globbing is supported. This means that wildcards can only be presents in the last element of `segments`. @type segments: C{list} @param segments: List of path elements as used by the FTP server protocol. @rtype: Boolean @return: True if `segments` contains a globbing expression. FrRT)fnmatch translate_testTranslationreplace)segments globCandidateglobTranslationsnonGlobTranslationsr3r3r4_isGlobbingExpressions r]c@ eZdZdZddZddZdS) FTPCmdErrorz- Generic exception for FTP commands. cGstj|g|R||_dSN) Exception__init__ errorMessage)selfmsgr3r3r4rbs zFTPCmdError.__init__cCst|j|jS)zA Generate a FTP response message for this error. )RESPONSE errorCodercrdr3r3r4responseszFTPCmdError.responseN)r/r0r1r2rbrir3r3r3r4r_ s r_c@eZdZdZeZdS)rFzH Raised when trying to access a non existent file or directory. N)r/r0r1r2FILE_NOT_FOUNDrgr3r3r3r4rFrFc@rj)AnonUserDeniedErrorz[ Raised when an anonymous user issues a command that will alter the filesystem N)r/r0r1r2ANON_USER_DENIEDrgr3r3r3r4rm"rmc@rj)rIz[ Raised when access is attempted to a resource to which access is not allowed. N)r/r0r1r2PERMISSION_DENIEDrgr3r3r3r4rI+rorIc@rj)rKzE Raised when RMD is called on a path that isn't a directory. N)r/r0r1r2 IS_NOT_A_DIRrgr3r3r3r4rK4rlrKc@rj)rMzA Raised when attempted to override an existing resource. N)r/r0r1r2 FILE_EXISTSrgr3r3r3r4rM<rlrMc@rj)rOzC Raised when DELE is called on a path that is a directory. N)r/r0r1r2IS_A_DIRrgr3r3r3r4rODrlrOc@rj)CmdSyntaxErrorz0 Raised when a command syntax is wrong. N)r/r0r1r2 SYNTAX_ERRrgr3r3r3r4rtLrlrtc@rj)CmdArgSyntaxErrorz^ Raised when a command is called with wrong value or a wrong number of arguments. N)r/r0r1r2SYNTAX_ERR_IN_ARGSrgr3r3r3r4rvTrorvc@rj)CmdNotImplementedErrorzF Raised when an unimplemented command is given to the server. N)r/r0r1r2CMD_NOT_IMPLMNTDrgr3r3r3r4rx]rlrxc@rj)CmdNotImplementedForArgErrorze Raised when the handling of a parameter for a command is not implemented by the server. N)r/r0r1r2CMD_NOT_IMPLMNTD_FOR_PARAMrgr3r3r3r4rzerorzc@ eZdZdS)FTPErrorNr/r0r1r3r3r3r4r}nr}c@r|)PortConnectionErrorNr~r3r3r3r4rrrrc@rj)BadCmdSequenceErrorzS Raised when a client sends a series of commands in an illogical sequence. N)r/r0r1r2 BAD_CMD_SEQrgr3r3r3r4rvrlrc@rj)AuthorizationErrorz2 Raised when client authentication fails. N)r/r0r1r2 AUTH_FAILURErgr3r3r3r4r~rlrcGstjdt|dddS)NzdebugDeferred(): %sTdebug)rrestr)rd_r3r3r4 debugDeferredsr) NJanFebMarAprMayJunJulAugSepOctNovDecc@seZdZdZdZdZdZdZddZddZ dd Z d d Z d d Z ddZ ddZddZddZddZddZddZddZddZd d!ZdS)"DTPFNlatin-1cCsd|_|jjdg|_dSNT) isConnectedfactorydeferredcallback_bufferrhr3r3r4connectionMades zDTP.connectionMadecCs$d|_|jdur|jddSdSNF)r _onConnLostrrdreasonr3r3r4connectionLosts zDTP.connectionLostcCs|j|ddS)zv Send a line to data channel. @param line: The line to be sent. @type line: L{bytes} s N transportwriterdliner3r3r4sendLinesz DTP.sendLinec CsZdd} d} | |r dp d|||dd|dd|| t|d|j} | |S) a Helper method to format one entry's info into a text entry like: 'drwxrwxrwx 0 user group 0 Jan 01 1970 filename.txt' @param name: C{bytes} name of the entry (file or directory or link) @param size: C{int} size of the entry @param directory: evals to C{bool} - whether the entry is a directory @param permissions: L{twisted.python.filepath.Permissions} object representing that entry's permissions @param hardlinks: C{int} number of hardlinks @param modified: C{float} - entry's last modified time in seconds since the epoch @param owner: C{str} username of the owner @param group: C{str} group name of the owner @return: C{str} in the requisite format cSsBt}t|j|j|j|j|jd}|j|jkrd|Sd|S)N)monthdayyearhourminutez%(month)s %(day)02d %(year)5dz+%(month)s %(day)02d %(hour)02d:%(minute)02d)timegmtime_monthstm_montm_mdaytm_yeartm_hourtm_min)mtimenowinfor3r3r4 formatDates z.DTP._formatOneListResponse..formatDatezY%(directory)s%(permissions)s%(hardlinks)4d %(owner)-9s %(group)-9s %(size)15d %(date)12s d-N) directory permissions hardlinksownergroupsizedate) shorthandrrencode _encoding) rdnamerrrrmodifiedrrrformatrer3r3r4_formatOneListResponses       zDTP._formatOneListResponsecCs||j|g|RdSr`)rr)rdrrir3r3r4sendListResponseszDTP.sendListResponsecCs|j||Sr`rregisterProducerrdproducer streamingr3r3r4rzDTP.registerProducercCs|j|jdSr`)runregisterProducerloseConnectionrhr3r3r4rs zDTP.unregisterProducercCs|jr |j|Std)NzCrap damn crap damn crap damn)rrrrarddatar3r3r4rs z DTP.writecCs2z |j|WdSty|jYdSwr`)_consr BaseExceptionrerrbackrdbytesr3r3r4 _conswrites  zDTP._conswritecCs(|jdur ||dS|j|dSr`)rrrr=rr3r3r4 dataReceiveds zDTP.dataReceivedcCs|jd|_|`|Sr`)rrrrdignoredr3r3r4_unregConsumer s zDTP._unregConsumercCs||jdusJ||_|j|d|jD]}||qd|_|jr1t|_}||j |S|j d|_t dSr) rrrrrr DeferredraddBothrrsucceed)rdconschunkrr3r3r4registerConsumers     zDTP.registerConsumercC|jdSr`)rresumeProducingrhr3r3r4r#rzDTP.resumeProducingcCrr`)rpauseProducingrhr3r3r4r&rzDTP.pauseProducingcCrr`)r stopProducingrhr3r3r4r)rzDTP.stopProducing)r/r0r1rrrrrrrrrrrrrrrrrrrrr3r3r3r4rs* 6 rc@sdeZdZdZeZeZeZeZdZ dddZ ddZ dd Z d d Z d d ZddZddZdS) DTPFactorya Client factory for I{data transfer process} protocols. @ivar peerCheck: perform checks to make sure the ftp-pi's peer is the same as the dtp's @ivar pi: a reference to this factory's protocol interpreter @ivar _state: Indicates the current state of the DTPFactory. Initially, this is L{_IN_PROGRESS}. If the connection fails or times out, it is L{_FAILED}. If the connection succeeds before the timeout, it is L{_FINISHED}. @cvar _IN_PROGRESS: Token to signal that connection is active. @type _IN_PROGRESS: L{object}. @cvar _FAILED: Token to signal that connection has failed. @type _FAILED: L{object}. @cvar _FINISHED: Token to signal that connection was successfully closed. @type _FINISHED: L{object}. FNcCs:||_||_t|_d|_|durddlm}||_dS)z Constructor @param pi: this factory's protocol interpreter @param peerHost: if peerCheck is True, this is the tuple that the generated instance will use to perform security checks Nrr ) pipeerHostr rr delayedCalltwisted.internetr _reactor)rdrrr r3r3r4rbNs   zDTPFactory.__init__cCsNtjddd|j|jurdS|j|_|t}||_|j|_||j_ |S)NDTPFactory.buildProtocolTr) rre_state _IN_PROGRESS _FINISHED cancelTimeoutrrr dtpInstancerdaddrpr3r3r4 buildProtocol_s rcCstjddd|dS)NzdtpFactory.stopFactoryTr)rrerrhr3r3r4 stopFactoryms zDTPFactory.stopFactorycCsFtd|j|jur dS|j|_|j}d|_|tt ddS)Nz$timed out waiting for DTP connectionzDTPFactory timeout) rrerr_FAILEDrrrr TimeoutError)rdrr3r3r4timeoutFactoryqs  zDTPFactory.timeoutFactorycCs8|jdur|jrtjddd|jdSdSdS)Nzcancelling DTP timeoutTr)ractiverrecancelrhr3r3r4r{szDTPFactory.cancelTimeoutcCs$td||j||j|_dS)Nz'DTPFactory.setTimeout set to %s seconds)rrer callLaterrr)rdsecondsr3r3r4 setTimeoutszDTPFactory.setTimeoutcCs6|j|jurdS|j|_|j}d|_|t|dSr`)rrrrrr)rd connectorrrr3r3r4clientConnectionFaileds z!DTPFactory.clientConnectionFailed)NN)r/r0r1r2objectrrrr peerCheckrbrrrrrrr3r3r3r4r-s   rc@seZdZddZddZdS)ASCIIConsumerWrappercCsP||_|j|_|j|_tjdksttjdksJdtjdkr&|j|_dSdS)N rTz6Unsupported platform (yea right like this even exists))rrroslineseplenr)rdrr3r3r4rbs  zASCIIConsumerWrapper.__init__cCs|j|tjdS)Nr )rrrXr r rr3r3r4rszASCIIConsumerWrapper.writeN)r/r0r1rbrr3r3r3r4r s r c@s0eZdZdZddZddZddZdd Zd S) FileConsumerz A consumer for FTP input that writes data to a file. @ivar fObj: a file object opened for writing, used to write data received. @type fObj: C{file} cC ||_dSr`)fObjrdrr3r3r4rb zFileConsumer.__init__cCs||_|sJdSr`)rrr3r3r4r zFileConsumer.registerProducercCsd|_|jdSr`)rrcloserhr3r3r4rszFileConsumer.unregisterProducercC|j|dSr`)rrrr3r3r4rzFileConsumer.writeN)r/r0r1r2rbrrrr3r3r3r4rs  rc@eZdZdZdZddZdS)FTPOverflowProtocolz:FTP mini-protocol for when there are too many connections.rcCs$|tt|j|jdSr`)rrfTOO_MANY_CONNECTIONSrrrrrhr3r3r4rsz"FTPOverflowProtocol.connectionMadeN)r/r0r1r2rrr3r3r3r4rs rcseZdZdZdZed\ZZZZ dZ dZ dZ dZ dZdZdZddgZgd Zed d ZejZd Zd dZfddZddZddZddZddZddZddZddZ dd Z!d!d"Z"d#d$Z#d%d&Z$d\d(d)Z%d*d+Z&d,d-Z'd.d/Z(d0d1Z)d2d3Z*d4d5Z+d6d7Z,d8d9Z-d:d;Z.dd?Z0d@dAZ1dBdCZ2dDdEZ3dFdGZ4dHdIZ5dJdKZ6dLdMZ7dNdOZ8dPdQZ9dRdSZ:dTdUZ;dVdWZZ?S)]FTPa; Protocol Interpreter for the File Transfer Protocol @ivar state: The current server state. One of L{UNAUTH}, L{INAUTH}, L{AUTHED}, L{RENAMING}. @ivar shell: The connected avatar @ivar binary: The transfer mode. If false, ASCII. @ivar dtpFactory: Generates a single DTP for this session @ivar dtpPort: Port returned from listenTCP @ivar listenFactory: A callable with the signature of L{twisted.internet.interfaces.IReactorTCP.listenTCP} which will be used to create Ports for passive connections (mainly for testing). @ivar passivePortRange: iterator used as source of passive port numbers. @type passivePortRange: C{iterator} @cvar UNAUTH: Command channel is not yet authenticated. @type UNAUTH: L{int} @cvar INAUTH: Command channel is in the process of being authenticated. @type INAUTH: L{int} @cvar AUTHED: Command channel was successfully authenticated. @type AUTHED: L{int} @cvar RENAMING: Command channel is between the renaming command sequence. @type RENAMING: L{int} F NTFEATQUIT)rMDTMPASVSIZEzTYPE A;IrrTrcGst||}||dSr`)rfr)rdkeyargsrer3r3r4replys z FTP.replycs&t|tr ||j}t|dS)za (Private) Encodes and sends a line @param line: L{bytes} or L{unicode} N) isinstancerrrsuperrr __class__r3r4rs  z FTP.sendLinecCs(|j|_||j|t|jjdSr`)UNAUTHstatertimeOutr$ WELCOME_MSGrwelcomeMessagerhr3r3r4rs zFTP.connectionMadecCsJ|jr||dt|jdr|jjdur|jd|_d|_dS)Nlogout) dtpFactory cleanupDTPrhasattrshellr.rrr3r3r4r s   zFTP.connectionLostcCrr`rrrhr3r3r4timeoutConnectionrzFTP.timeoutConnectionc sttkr|j}fdd}fdd}fdd}|d}|dkr>|d|||d df}n|d }tjj g|R}| ||| t j d d lm}|d |j|dS) NcsxtrjdStr*tfdddDr*tddSt dt t ddS)Nc3s |] }|jjdvVqdS)rN)valuer#).0reerrr3r4 #s  z:FTP.lineReceived..processFailed..)z takes exactlyzrequired positional argumentz requires an argument.zUnexpected FTP errorzinternal server error) checkr_rr5ri TypeErroranyr$rurrer8REQ_ACTN_NOT_TAKENr7cmdrdr7r4 processFailed s   z'FTP.lineReceived..processFailedcs2t|tr j|dS|dur|dSdSr`)r%tupler$resultrhr3r4processSucceeded-s z*FTP.lineReceived..processSucceededcsjs dSdSr`) disconnectedrrrhr3r4allDone3s z!FTP.lineReceived..allDone rSrTr3rr) resetTimeoutrrrdecoderfindr maybeDeferredprocessCommand addCallbacks addErrbackrr8rr rr) rdrr@rDrG spaceIndexr#rr r3r>r4 lineReceiveds$       zFTP.lineReceivedcsfdd}|}|jvr||Sjjkr-|dkr#jS|dkr+tdfStSjjkr@|dkr<jStdfSjj krJ||Sjj kr]|dkrYj StdfSdS) Ncs.td|d}|dur|Stt|S)Nftp_)getattrr rErx)commandmethodparamsrdr3r4call_ftp_commandJsz,FTP.processCommand..call_ftp_commandUSERPASSzUSER required before PASSzPASS required after USERRNTOzRNTO required after RNFR) upperPUBLIC_COMMANDSr*r)ftp_USERr NOT_LOGGED_ININAUTHftp_PASSAUTHEDRENAMINGftp_RNTO)rdr?rWrXr3rVr4rMIs*        zFTP.processCommandc CsL|jD]}z |||}W|StjyYqwtd|d|j)ze Return a port for passive access, using C{self.passivePortRange} attribute. r7zNo port available in range )passivePortRange listenFactoryrCannotListenError)rdrportndtpPortr3r3r4 getDTPPortls zFTP.getDTPPortcCsB|s ttdS||_|j|_|jjr|j|jjkrt St |fS)zc First part of login. Get the username the peer wants to authenticate as. zUSER requires an argument) r rErt_userr`r*rallowAnonymous userAnonymousGUEST_NAME_OK_NEED_EMAILUSR_NAME_OK_NEED_PASS)rdusernamer3r3r4r^|sz FTP.ftp_USERcstjjrjjjkrt}tn tj|}t`fdd}fdd}j |dt }| |||S)zf Second part of login. Get the password the peer wants to authenticate with. cs8|\}}}|tus Jd|_|_g_j_S)NzThe realm is busted, jerk.) IFTPShellr2r.workingDirectoryrbr*)rC interfaceavatarr.r$rdr3r4_cbLogins zFTP.ftp_PASS.._cbLogincs|tjtjj_tr`)trap cred_errorUnauthorizedLoginUnhandledCredentialsr)r*rrrhr3r4_ebLoginszFTP.ftp_PASS.._ebLoginN) rrlrkrmr AnonymousGUEST_LOGGED_IN_PROCEEDUsernamePasswordUSR_LOGGED_IN_PROCEEDrloginrqrN)rdpasswordcredsrvr|rr3rur4ras  z FTP.ftp_PASScCsv|jdur |t|d|_|j|j||j|_|jj }|jj }| t t |||jjddS)a Request for a passive connection from the rfc:: This command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command. The response to this command includes the host and port address this server is listening on. N)rcSdSr`r3ignr3r3r4zFTP.ftp_PASV..)r/r0rr dtpTimeoutrjrirgetHosthostportr$ENTERING_PASV_MODEencodeHostPortr addCallback)rdrrr3r3r4ftp_PASVs    z FTP.ftp_PASVcCsttt|d}dt|dd}|dd>|dB}|jdur'|t||jj d|_|j |j t |||j|_dd}d d }|jj||S) N,z %d.%d.%d.%drr)rrcStSr`)ENTERING_PORT_MODErFr3r3r4 connectedzFTP.ftp_PORT..connectedcSs|ttSr`)rwrCANT_OPEN_DATA_CNXr7r3r3r4 connFaileds z FTP.ftp_PORT..connFailed)rAmapintr;r/r0rrgetPeerrrrr connectTCPrirrN)rdaddressriprrrr3r3r4ftp_PORTs z FTP.ftp_PORTcCst|tr |dS|S)a Encode C{name} to be sent over the wire. This encodes L{unicode} objects as UTF-8 and leaves L{bytes} as-is. As described by U{RFC 3659 section 2.2}:: Various FTP commands take pathnames as arguments, or return pathnames in responses. When the MLST command is supported, as indicated in the response to the FEAT command, pathnames are to be transferred in one of the following two formats. pathname = utf-8-name / raw utf-8-name = raw = Which format is used is at the option of the user-PI or server-PI sending the pathname. @param name: Name to be encoded. @type name: L{bytes} or L{unicode} @return: Wire format of C{name}. @rtype: L{bytes} zutf-8)r%rr)rdrr3r3r4 _encodeNames  zFTP._encodeNamer7csjdus jjsttdS|dvrd}fdd}ztj|}Wnty6tt |YSwj |d}| ||S)aThis command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current information on the file. A null argument implies the user's current working or default directory. N"must send PORT or PASV before RETR)z-az-lz-laz-alr7csBt|D]\}}|}j||qjjtfSr`)r$DATA_CNX_ALREADY_OPEN_START_XFRrrrrrTXFR_COMPLETE_OK)resultsrattrsrhr3r4 gotListings    z FTP.ftp_LIST..gotListing)rrrrrrr) rrr rErlowerrBrrr.rFr2listr)rdr?rrYrr3rhr4ftp_LISTs      z FTP.ftp_LISTcsjdus jjsttdSztj|}Wnty(tt|YSwfdd}fdd}t |r>| }nd}j |}| |||||S)a\ This command causes a directory listing to be sent from the server to the client. The pathname should specify a directory or other system-specific file group descriptor. An empty path implies the current working directory. If the path is non-existent, send nothing. If the path is to a file, send only the file name. @type path: C{str} @param path: The path for which a directory listing should be returned. @rtype: L{Deferred} @return: a L{Deferred} which will be fired when the listing request is finished. NrcsTt|D]\}}|r|r t||r |}j|qjjtfS)a Send, line by line, each matching file in the directory listing, and then close the connection. @type results: A C{list} of C{tuple}. The first element of each C{tuple} is a C{str} and the second element is a C{list}. @param results: The names of the files in the directory. @param glob: A shell-style glob through which to filter results (see U{http://docs.python.org/2/library/fnmatch.html}), or L{None} for no filtering. @type glob: L{str} or L{None} @return: A C{tuple} containing the status code for a successful transfer. @rtype: C{tuple} ) r$rrUrrrrrr)rglobrrrhr3r4cbListCs     zFTP.ftp_NLST..cbListcsjjtfS)a RFC 959 specifies that an NLST request may only return directory listings. Thus, send nothing and just close the connection. @type results: L{Failure} @param results: The L{Failure} wrapping a L{FileNotFoundError} that occurred while trying to list the contents of a nonexistent directory. @returns: A C{tuple} containing the status code for a successful transfer. @rtype: C{tuple} )rrrr)rrhr3r4listErr]s zFTP.ftp_NLST..listErr)rrr rErrBrrr.rFr]r<r2rrrO)rdr?rYrrrrr3rhr4ftp_NLST+s        z FTP.ftp_NLSTcsRztj|Wntytt|YSwfdd}j|S)Ncs _tfSr`)rrREQ_FILE_ACTN_COMPLETED_OKrBrYrdr3r4 accessGrantedsz"FTP.ftp_CWD..accessGranted) rBrrr.r rErFr2accessr)rdr?rr3rr4ftp_CWD{s z FTP.ftp_CWDcC |dS)Nr8)rrhr3r3r4ftp_CDUPrz FTP.ftp_CDUPcCstdd|jfS)Nr5) PWD_REPLYjoinrrrhr3r3r4ftp_PWDsz FTP.ftp_PWDcsjdur tdztj|Wnty!tt|YSwdfdd}j s6t jnjddddfd d }fd d }j }| |||||S) a This command causes the content of a file to be sent over the data transfer channel. If the path is to a folder, an error will be raised. @type path: C{str} @param path: The path to the file which should be transferred over the data transfer channel. @rtype: L{Deferred} @return: a L{Deferred} which will be fired when the transfer is done. Nz!PORT or PASV required before RETRcjj|Sr`rrr+rBrhr3r4 enableTimeoutz#FTP.ftp_RETR..enableTimeoutcStfSr`rrBr3r3r4cbSentzFTP.ftp_RETR..cbSentcSs(tdt||tr|StfS)Nz7Unexpected error attempting to transmit file to client:)rrer8r:r_CNX_CLOSED_TXFR_ABORTEDr7r3r3r4ebSents   zFTP.ftp_RETR..ebSentcs8jjr tnt|}||Sr`)rrr$rFILE_STATUS_OK_OPEN_DATA_CNXsendrNfiler)rrrrdr3r4cbOpeneds     zFTP.ftp_RETR..cbOpenedcsL|tttstdt||tr|jj d fSt d fS)Nz:Unexpected error attempting to open file for transmission:r5) r:rIrFrOrrer8r_r5rgrrkr7newsegsr3r4ebOpeneds   zFTP.ftp_RETR..ebOpened)rrrBrrr.r rErFrbinaryr r2openForReadingrNrrdr?rrrrr3)rrrrrdr4ftp_RETRs(       z FTP.ftp_RETRcsjdur tdztj|Wnty!tt|YSwdfdd}fdd}fdd}fd d d d d dj }| ||| ||S)a STORE (STOR) This command causes the server-DTP to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist. Nz!PORT or PASV required before STORcrr`rrBrhr3r4rrz#FTP.ftp_STOR..enableTimeoutcs4}||fdd||S)zx File was open for reading. Launch the data transfer channel via the file consumer. csSr`)rrFrr3r4rz0FTP.ftp_STOR..cbOpened..)receiverrNr) cbConsumerrrrr4rs   zFTP.ftp_STOR..cbOpenedcs8t|jtr|jjdfSt|dtdfS)z Called when failed to open the file for reading. For known errors, return the FTP error code. For all other, return a file not found error. r5z-Unexpected error received while opening file:)r%r5r_rgrrr8rkr7rr3r4rs  zFTP.ftp_STOR..ebOpenedcs>jst|}j|}jjrt|St|S)z Called after the file was opended for reading. Prepare the data transfer channel and send the response to the command channel. )rr rrrr$rr)rrrhr3r4r s   z FTP.ftp_STOR..cbConsumercSr)zK Called from data transport when transfer is done. rrBr3r3r4r!szFTP.ftp_STOR..cbSentcSs t|d|tr |StfS)zk Called from data transport when there are errors during the transfer. z*Unexpected error received during transfer:)rr8r:r_rr7r3r3r4r's  zFTP.ftp_STOR..ebSent) rrrBrrr.r rErFrr2openForWritingrNrrr3)rrrrrdr4ftp_STORs$       z FTP.ftp_STORcCNzt|j|}Wntytt|YSwdd}|j|d|S)ab File SIZE The FTP command, SIZE OF FILE (SIZE), is used to obtain the transfer size of a file from the server-FTP process. This is the exact number of octets (8 bit bytes) that would be transmitted over the data connection should that file be transmitted. This value will change depending on the current STRUcture, MODE, and TYPE of the data connection or of a data connection that would be created were one created now. Thus, the result of the SIZE command is dependent on the currently established STRU, MODE, and TYPE parameters. The SIZE command returns how many octets would be transferred if the file were to be transferred using the current transfer structure, mode, and type. This command is normally used in conjunction with the RESTART (REST) command when STORing a file to a remote server in STREAM mode, to determine the restart point. The server-PI might need to read the partially transferred file, do any appropriate conversion, and count the number of octets that would be generated when sending the file in order to correctly respond to this command. Estimates of the file transfer size MUST NOT be returned; only precise information is acceptable. http://tools.ietf.org/html/rfc3659 cSs|\}tt|fSr`) FILE_STATUSr)rCrr3r3r4cbStatWrzFTP.ftp_SIZE..cbStat)r rBrrr.r rErFr2statrrdr?rrr3r3r4ftp_SIZE8s z FTP.ftp_SIZEcCr)a! File Modification Time (MDTM) The FTP command, MODIFICATION TIME (MDTM), can be used to determine when a file in the server NVFS was last modified. This command has existed in many FTP servers for many years, as an adjunct to the REST command for STREAM mode, thus is widely available. However, where supported, the "modify" fact that can be provided in the result from the new MLST command is recommended as a superior alternative. http://tools.ietf.org/html/rfc3659 cSs|\}ttdt|fS)Nz %Y%m%d%H%M%S)rrstrftimer)rCrr3r3r4roszFTP.ftp_MDTM..cbStat)rrrr3r3r4ftp_MDTM]s  z FTP.ftp_MDTMcCsH|}|r!t|d|dd}|dur||ddS||StfS)a REPRESENTATION TYPE (TYPE) The argument specifies the representation type as described in the Section on Data Representation and Storage. Several types take a second parameter. The first parameter is denoted by a single Telnet character, as is the second Format parameter for ASCII and EBCDIC; the second parameter for local byte is a decimal integer to indicate Bytesize. The parameters are separated by a (Space, ASCII code 32). type_rNrT)r\rS type_UNKNOWNru)rdtyperfr3r3r4ftp_TYPEus  z FTP.ftp_TYPEcCs0|dks|dkrd|_td|fStt|S)Nr7NFAr TYPE_SET_OKr rErvrdcoder3r3r4type_As z FTP.type_AcCs$|dkr d|_tdfStt|S)Nr7TIrrr3r3r4type_Isz FTP.type_IcCstt|Sr`)r rErzrr3r3r4rrzFTP.type_UNKNOWNcCrr`) NAME_SYS_TYPErhr3r3r4ftp_SYSTrz FTP.ftp_SYSTcC$|}|dkr tfStt|S)NFr\CMD_OKr rErz)rd structurerr3r3r4ftp_STRUz FTP.ftp_STRUcCr)NSr)rdmoderr3r3r4ftp_MODErz FTP.ftp_MODEcsLzt|j}WntyttYSw|j|fddS)NcstfSr`) MKD_REPLYrr?r3r4rrzFTP.ftp_MKD..) rBrrr.r rErFr2 makeDirectoryrrdr?rr3rr4ftp_MKDs   z FTP.ftp_MKDcCHzt|j|}Wntytt|YSw|j|ddS)NcSrr`rrr3r3r4rzFTP.ftp_RMD..) rBrrr.r rErFr2removeDirectoryrrr3r3r4ftp_RMD  z FTP.ftp_RMDcCr)NcSrr`rrr3r3r4rrzFTP.ftp_DELE..) rBrrr.r rErFr2 removeFilerrr3r3r4ftp_DELErz FTP.ftp_DELEcCrr`)rrhr3r3r4ftp_NOOPrz FTP.ftp_NOOPcCs||_|j|_tfSr`) _fromNamercr*"REQ_FILE_ACTN_PENDING_FURTHER_INFO)rdfromNamer3r3r4ftp_RNFRsz FTP.ftp_RNFRcCsh|j}|`|j|_zt|j|}t|j|}Wnty'tt|YSw|j || ddS)NcSrr`rrr3r3r4rrzFTP.ftp_RNTO..) rrbr*rBrrr.r rErFr2renamer)rdtoNamerfromsegstosegsr3r3r4rds  z FTP.ftp_RNTOcCsB|ttd|jD] }|d|q |ttddS)zm Advertise the features supported by the server. http://tools.ietf.org/html/rfc2389 rrHrTN)rrfFEAT_OKFEATURES)rdfeaturer3r3r4ftp_FEATs z FTP.ftp_FEATcCs |t|S)zl Handle OPTS command. http://tools.ietf.org/html/draft-ietf-ftpext-utf-8-option-00 )r$OPTS_NOT_IMPLEMENTED)rdoptionr3r3r4ftp_OPTSs z FTP.ftp_OPTScCs|t|jd|_dSr)r$ GOODBYE_MSGrrrErhr3r3r4ftp_QUITs   z FTP.ftp_QUITcCstjdddt|j|jd}|_tj|r|ntj|r*|nJd|f|j d|_ |j durCd|_ dSdS)z0 Call when DTP connection exits r0TrNFz@dtpPort should be an IListeningPort or IConnector, instead is %r) rrerir IListeningPort providedBy stopListening IConnector disconnectr/rr)rdrir3r3r4r0s"        zFTP.cleanupDTP)r7)@r/r0r1r2rEranger)r`rbrcrrr2r/rirrr]rrer listenTCPrfrr$rrrr4rQrMrjr^rarrrrrrrrrrrrrrrrrrrrrrrrrdrrrr0 __classcell__r3r3r'r4rsn    /#! -P J`%    rc@sVeZdZdZeZeZdZdZ dZ de j dZ eddZdd d Zd d ZddZd S) FTPFactorya A factory for producing ftp protocol instances @ivar timeOut: the protocol interpreter's idle timeout time in seconds, default is 600 seconds. @ivar passivePortRange: value forwarded to C{protocol.passivePortRange}. @type passivePortRange: C{iterator} T anonymousiXzTwisted z FTP ServerrrTNcCs||_||_g|_dSr`)rrm instances)rdrrmr3r3r4rb!s zFTPFactory.__init__cCs8tj||}|dur|j|j_|j|j_|j|j_|Sr`)rLimitTotalConnectionsFactoryrrwrappedProtocolr+rerr3r3r4r&s    zFTPFactory.buildProtocolcCs dd|jDtj|dS)NcSs g|] }|jdur|dqSr`)r+rr6rr3r3r4 1s z*FTPFactory.stopFactory..)r rr!rrhr3r3r4r.szFTPFactory.stopFactory)Nr)r/r0r1r2rr roverflowProtocolrlrmr+rversionr-rrerbrrr3r3r3r4r s    rc@s\eZdZdZddZddZddZdd Zd d Zdd dZ dddZ ddZ ddZ dS)rqz An abstraction of the shell commands used by the FTP protocol for a given user account. All path names must be absolute. cCdS)a Create a directory. @param path: The path, as a list of segments, to create @type path: C{list} of C{unicode} @return: A Deferred which fires when the directory has been created, or which fails if the directory cannot be created. Nr3rr3r3r4r@rzIFTPShell.makeDirectorycCr')a Remove a directory. @param path: The path, as a list of segments, to remove @type path: C{list} of C{unicode} @return: A Deferred which fires when the directory has been removed, or which fails if the directory cannot be removed. Nr3rr3r3r4rKrzIFTPShell.removeDirectorycCr')a  Remove a file. @param path: The path, as a list of segments, to remove @type path: C{list} of C{unicode} @return: A Deferred which fires when the file has been removed, or which fails if the file cannot be removed. Nr3rr3r3r4rVrzIFTPShell.removeFilecCr')ax Rename a file or directory. @param fromPath: The current name of the path. @type fromPath: C{list} of C{unicode} @param toPath: The desired new name of the path. @type toPath: C{list} of C{unicode} @return: A Deferred which fires when the path has been renamed, or which fails if the path cannot be renamed. Nr3)fromPathtoPathr3r3r4r arzIFTPShell.renamecCr')a Determine whether access to the given path is allowed. @param path: The path, as a list of segments @return: A Deferred which fires with None if access is allowed or which fails with a specific exception type if access is denied. Nr3rr3r3r4rorzIFTPShell.accessr3cCr')z Retrieve information about the given path. This is like list, except it will never return results about child paths. Nr3r?keysr3r3r4rzrzIFTPShell.statcCr')ae Retrieve information about the given path. If the path represents a non-directory, the result list should have only one entry with information about that non-directory. Otherwise, the result list should have an element for each child of the directory. @param path: The path, as a list of segments, to list @type path: C{list} of C{unicode} or C{bytes} @param keys: A tuple of keys desired in the resulting dictionaries. @return: A Deferred which fires with a list of (name, list), where the name is the name of the entry as a unicode string or bytes and each list contains values corresponding to the requested keys. The following are possible elements of keys, and the values which should be returned for them: - C{'size'}: size in bytes, as an integer (this is kinda required) - C{'directory'}: boolean indicating the type of this entry - C{'permissions'}: a bitvector (see os.stat(foo).st_mode) - C{'hardlinks'}: Number of hard links to this entry - C{'modified'}: number of seconds since the epoch since entry was modified - C{'owner'}: string indicating the user owner of this entry - C{'group'}: string indicating the group owner of this entry Nr3r*r3r3r4rrzIFTPShell.listcCr')z @param path: The path, as a list of segments, to open @type path: C{list} of C{unicode} @rtype: C{Deferred} which will fire with L{IReadFile} Nr3rr3r3r4rrzIFTPShell.openForReadingcCr')z @param path: The path, as a list of segments, to open @type path: C{list} of C{unicode} @rtype: C{Deferred} which will fire with L{IWriteFile} Nr3rr3r3r4rrzIFTPShell.openForWritingNr3) r/r0r1r2rrrr rrrrrr3r3r3r4rq8s    % rqc@eZdZdZddZdS) IReadFilez0 A file out of which bytes may be read. cCr')a Produce the contents of the given path to the given consumer. This method may only be invoked once on each provider. @type consumer: C{IConsumer} @return: A Deferred which fires when the file has been consumed completely. Nr3)consumerr3r3r4rrzIReadFile.sendN)r/r0r1r2rr3r3r3r4r.s r.c@r^) IWriteFilez1 A file into which bytes may be written. cCr')z Create a consumer which will write to this file. This method may only be invoked once on each provider. @rtype: C{Deferred} of C{IConsumer} Nr3r3r3r3r4rrzIWriteFile.receivecCr')ae Perform any post-write work that needs to be done. This method may only be invoked once on each provider, and will always be invoked after receive(). @rtype: C{Deferred} of anything: the value is ignored. The FTP client will not see their upload request complete until this Deferred has been fired. Nr3r3r3r3r4rrzIWriteFile.closeN)r/r0r1r2rrr3r3r3r4r0s r0cCsDg}t|}||jtD]}|j|jvr||jq|S)z_ Return the primary and supplementary groups for the given UID. @type uid: C{int} ) pwdgetpwuidr=pw_gidgrpgetgrallpw_namegr_memgr_gid)uidrCpwentgrentr3r3r4 _getgroupss     r<rc Cs|dkrtj}tj}tj}tj}n|dkr"tj}tj}tj}tj }nt d|dd}tj |r`|dkr9d}n't|} || j @rK|| jkrKd}n|| j @rY|t|vrYd}n|| j @r`d}|rut||sud}td|tf|S) a checks to see if uid has proper permissions to access path with mode @type uid: C{int} @param uid: numeric user id @type gid: C{int} @param gid: numeric group id @type spath: C{str} @param spath: the path on the server to test @type mode: C{str} @param mode: 'r' or 'w' (read or write) @rtype: C{bool} @return: True if the given credentials have the specified form of access to the given path r=wz Invalid mode z: must specify 'r' or 'w'FrTzUFilesystem grants permission to UID %d but it is inaccessible to me running as UID %d)rS_IRUSRS_IRGRPS_IROTHr R_OKS_IWUSRS_IWGRPS_IWOTHW_OK ValueErrorr?existsst_modest_uidr<rrregetuid) r9gidspathrusrr4othamoderrAr3r3r4_testPermissionss>     rQc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ d,ddZd,ddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+S)-FTPAnonymousShellz An anonymous implementation of IFTPShell @type filesystemRoot: L{twisted.python.filepath.FilePath} @ivar filesystemRoot: The path which is considered the root of this shell. cCrr`)filesystemRoot)rdrSr3r3r4rb6rzFTPAnonymousShell.__init__cC |j|Sr`)rS descendantrdr?r3r3r4_path9 zFTPAnonymousShell._pathcC ttSr`r rErmrVr3r3r4r<rXzFTPAnonymousShell.makeDirectorycCrYr`rZrVr3r3r4r?rXz!FTPAnonymousShell.removeDirectorycCrYr`rZrVr3r3r4rBrXzFTPAnonymousShell.removeFilecCrYr`rZ)rdr(r)r3r3r4r ErXzFTPAnonymousShell.renamecCs||}ttSr`)rWr rErmrVr3r3r4rHs  zFTPAnonymousShell.receivec C||}|rtt|Sz|d}Wn$ty/}z t|j|WYd}~Sd}~wt y;tYSwt t |S)a Open C{path} for reading. @param path: The path, as a list of segments, to open. @type path: C{list} of C{unicode} @return: A L{Deferred} is returned that will fire with an object implementing L{IReadFile} if the file is successfully opened. If C{path} is a directory, or if an exception is raised while trying to open the file, the L{Deferred} will fire with an error. r=N) rWisdirr rErOopenOSErrorrQrCrr _FileReader)rdr?rrrPr3r3r4rLs   z FTPAnonymousShell.openForReadingcCsttdS)za Reject write attempts by anonymous users with L{PermissionDeniedError}. zSTOR not allowed)r rErIrVr3r3r4resz FTPAnonymousShell.openForWritingc Cs||}|stt|Sz|Wn$ty.}z t|j|WYd}~Sd}~wt y:tYSwt dSr`) rWrHr rErFlistdirr^rQrCrrrdr?rrPr3r3r4rls     zFTPAnonymousShell.accessr3c Cs||}|r;z|||}Wn$ty)}z t|j|WYd}~Sd}~wty5tYSwt |S| || ddS)NcSs |ddS)NrrTr3)resr3r3r4rs z(FTPAnonymousShell.stat..) rWr\ _statNoder^rQrCrr rErrr)rdr?r+r statResultrPr3r3r4r|s    zFTPAnonymousShell.statc s||r}fdd|D}nr*tjj|jg}g}nt t |Sg}t ||D]C\}g}| ||f|r{z |||Wq8tyl}zt|j|WYd}~Sd}~wtyzt YSwq8t |S)a Return the list of files at given C{path}, adding C{keys} stat informations if specified. @param path: the directory or file to check. @type path: C{str} @param keys: the list of desired metadata @type keys: C{list} of C{str} csg|]}|qSr3)childr#filePathr3r4r$sz*FTPAnonymousShell.list..N)rWr\r`isfiler r?r segmentsFromrSr rErFzipr=extendrcr^rQrCrr) rdr?r+entries fileEntriesrfileNameentrPr3rfr4rs.   zFTPAnonymousShell.listcsfdd|DS)z Shortcut method to get stat info on a node. @param filePath: the node to stat. @type filePath: C{filepath.FilePath} @param keys: the stat keys to get. @type keys: C{iterable} csg|] }td|qS)_stat_)rS)r6krgrdr3r4r$sz/FTPAnonymousShell._statNode..)restat)rdrgr+r3rrr4rcs zFTPAnonymousShell._statNodecC|S)z Get the filepath's size as an int @param fp: L{twisted.python.filepath.FilePath} @return: C{int} representing the size )getsizerdfpr3r3r4 _stat_sizezFTPAnonymousShell._stat_sizecCrt)z Get the filepath's permissions object @param fp: L{twisted.python.filepath.FilePath} @return: L{twisted.python.filepath.Permissions} of C{fp} )getPermissionsrvr3r3r4_stat_permissionsryz#FTPAnonymousShell._stat_permissionscCs z|WStyYdSw)a Get the number of hardlinks for the filepath - if the number of hardlinks is not yet implemented (say in Windows), just return 0 since stat-ing a file in Windows seems to return C{st_nlink=0}. (Reference: U{http://stackoverflow.com/questions/5275731/os-stat-on-windows}) @param fp: L{twisted.python.filepath.FilePath} @return: C{int} representing the number of hardlinks r)getNumberOfHardLinksNotImplementedErrorrvr3r3r4_stat_hardlinkss   z!FTPAnonymousShell._stat_hardlinkscCrt)z Get the filepath's last modified date @param fp: L{twisted.python.filepath.FilePath} @return: C{int} as seconds since the epoch )getModificationTimervr3r3r4_stat_modifiedryz FTPAnonymousShell._stat_modifiedcC\z|}Wn tyYdSwtdur*zt|dWSty)Yt|Swt|S)a Get the filepath's owner's username. If this is not implemented (say in Windows) return the string "0" since stat-ing a file in Windows seems to return C{st_uid=0}. (Reference: U{http://stackoverflow.com/questions/5275731/os-stat-on-windows}) @param fp: L{twisted.python.filepath.FilePath} @return: C{str} representing the owner's username 0Nr) getUserIDr}r1r2KeyErrorr)rdrwuserIDr3r3r4 _stat_owner   zFTPAnonymousShell._stat_ownercCr)a Get the filepath's owner's group. If this is not implemented (say in Windows) return the string "0" since stat-ing a file in Windows seems to return C{st_gid=0}. (Reference: U{http://stackoverflow.com/questions/5275731/os-stat-on-windows}) @param fp: L{twisted.python.filepath.FilePath} @return: C{str} representing the owner's group rNr) getGroupIDr}r4getgrgidrr)rdrwgroupIDr3r3r4 _stat_grouprzFTPAnonymousShell._stat_groupcCrt)z Get whether the filepath is a directory @param fp: L{twisted.python.filepath.FilePath} @return: C{bool} )r\rvr3r3r4_stat_directoryryz!FTPAnonymousShell._stat_directoryNr,)r/r0r1r2rbrWrrrr rrrrrrrcrxr{r~rrrrr3r3r3r4rR,s,  #     rRc@$eZdZddZddZddZdS)r_cC||_d|_dSr)r_sendrr3r3r4rb" z_FileReader.__init__cCsd|_|j|Sr)rrr)rd passthroughr3r3r4_close&s z_FileReader._closecCs6|jrJdd|_t|j|}||j|S)Nz0Can only call IReadFile.send *once* per instanceT)rr FileSenderbeginFileTransferrrr)rdr/rr3r3r4r+s  z_FileReader.sendN)r/r0r1rbrrr3r3r3r4r_ s r_c@s8eZdZdZddZddZddZdd Zd d Zd S) FTPShellz: An authenticated implementation of L{IFTPShell}. c Csj||}z|Wn$ty#}z t|j|WYd}~Sd}~wty/tYSwtdSr`) rWmakedirsr^rQrCrr rErrar3r3r4r8s     zFTPShell.makeDirectoryc Cs||}|rtt|Szt|jWn$ty0}z t |j |WYd}~Sd}~wt y<tYSwt dSr`) rWrhr rErKr rmdirr?r^rQrCrrrar3r3r4rCs    zFTPShell.removeDirectoryc Cs||}|rtt|Sz|Wn$ty.}z t|j|WYd}~Sd}~wt y:tYSwt dSr`) rWr\r rErOremover^rQrCrrrar3r3r4rSs     zFTPShell.removeFilec Cs|||}||}z t|j|jWn$ty,}z t|j|WYd}~Sd}~wty8t YSwt dSr`) rWr r r?r^rQrCrr rEr)rdr(r)rwtprPr3r3r4r cs     zFTPShell.renamec Cr[)a Open C{path} for writing. @param path: The path, as a list of segments, to open. @type path: C{list} of C{unicode} @return: A L{Deferred} is returned that will fire with an object implementing L{IWriteFile} if the file is successfully opened. If C{path} is a directory, or if an exception is raised while trying to open the file, the L{Deferred} will fire with an error. r>N) rWr\r rErOr]r^rQrCrr _FileWriter)rdr?rrrPr3r3r4ros   zFTPShell.openForWritingN) r/r0r1r2rrrr rr3r3r3r4r3s  rc@r)rcCrr)r_receiverr3r3r4rbrz_FileWriter.__init__cCs$|jrJdd|_tt|jS)Nz4Can only call IWriteFile.receive *once* per instanceT)rr rrrrhr3r3r4rsz_FileWriter.receivecCs tdSr`)r rrhr3r3r4rrz_FileWriter.closeN)r/r0r1rbrrr3r3r3r4rs rc@(eZdZdZddZddZddZdS) BaseFTPRealmz{ Base class for simple FTP realms which provides an easy hook for specifying the home directory for each user. cCst||_dSr`)rFilePath anonymousRoot)rdrr3r3r4rbrzBaseFTPRealm.__init__cCst|jd)a Return a L{FilePath} representing the home directory of the given avatar. Override this in a subclass. @param avatarId: A user identifier returned from a credentials checker. @type avatarId: C{str} @rtype: L{FilePath} z" did not override getHomeDirectory)r}r(rdavatarIdr3r3r4getHomeDirectorys zBaseFTPRealm.getHomeDirectorycGsX|D]%}|tur'|tjurt|j}nt||}t|t|dddfSqtd)Nr.cSrr`r3r3r3r3r4rrz,BaseFTPRealm.requestAvatar..z3Only IFTPShell interface is supported by this realm) rqr ANONYMOUSrRrrrrSr})rdrmindr ifacertr3r3r4 requestAvatars  zBaseFTPRealm.requestAvatarN)r/r0r1r2rbrrr3r3r3r4rs  rc@s"eZdZdZdddZddZdS) FTPRealma" @type anonymousRoot: L{twisted.python.filepath.FilePath} @ivar anonymousRoot: Root of the filesystem to which anonymous users will be granted access. @type userHome: L{filepath.FilePath} @ivar userHome: Root of the filesystem containing user home directories. /homecCst||t||_dSr`)rrbrruserHome)rdrrr3r3r4rbs zFTPRealm.__init__cCrT)z Use C{avatarId} as a single path segment to construct a child of C{self.userHome} and return that child. )rrerr3r3r4r zFTPRealm.getHomeDirectoryN)r)r/r0r1r2rbrr3r3r3r4rs rc@r-)SystemFTPRealmz L{SystemFTPRealm} uses system user account information to decide what the home directory for a particular avatarId is. This works on POSIX but probably is not reliable on Windows. cCs,tjd|}|drtt|S)zx Return the system-defined home directory of the system user account with the name C{avatarId}. ~)r r? expanduserr:rxryrr)rdrr?r3r3r4rs  zSystemFTPRealm.getHomeDirectoryN)r/r0r1r2rr3r3r3r4rs rc@r|)ConnectionLostNr~r3r3r3r4rrrc@r|) CommandFailedNr~r3r3r3r4rrrc@r|) BadResponseNr~r3r3r3r4rrrc@r|)UnexpectedResponseNr~r3r3r3r4r rrc@r|)UnexpectedDataNr~r3r3r3r4r rrc@seZdZdddZddZdS) FTPCommandNrcCs&||_t|_d|_||_d|_dS)NrT)textr rrreadypublictransferDeferred)rdrrr3r3r4rb s   zFTPCommand.__init__cCs|jr |j|dSdSr`)rrr)rdrr3r3r4rE szFTPCommand.failNr)r/r0r1rbrEr3r3r3r4r s  rc@s,eZdZddZddZddZddZd S) ProtocolWrappercCs||_||_dSr`)originalr)rdrrr3r3r4rb rzProtocolWrapper.__init__cCrr`)rmakeConnectionrdrr3r3r4r rzProtocolWrapper.makeConnectioncCrr`)rrrr3r3r4r rzProtocolWrapper.dataReceivedcCs|j||jddSr`)rrrrrr3r3r4r" s zProtocolWrapper.connectionLostN)r/r0r1rbrrrr3r3r3r4r s  rc@r-)IFinishableConsumerzA A Consumer for producers that finish. @since: 11.0 cCr')z6 The producer has finished producing. Nr3r3r3r3r4finish/ rzIFinishableConsumer.finishN)r/r0r1r2rr3r3r3r4r( s rc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)SenderProtocolcCst|_t|_dSr`)r rconnectedDeferredrrhr3r3r4rb7 s zSenderProtocol.__init__cCstd)Nzt| } | | fS) ze Decode an FTP response specifying a host and port. @return: a 2-tuple of (host, port). z[^0-9, ]r7cSsg|]}t|qSr3)rstripr#r3r3r4r$i z"decodeHostPort..rrz Out of ranger6r)resubr;rGr) rabcdefparsedxabcrrPrrrr3r3r4decodeHostPortb s rcCs,|dt|d?t|dg}d|S)Nr6rr)r;rr)rrnumbersr3r3r4rs s" rcCs|tj|jjSr`)rwr FirstErrorr5 subFailurer{r3r3r4_unwrapFirstErrorx s rc@r)FTPDataPortFactoryz_ Factory for data connections that use the PORT command (i.e. "active" transfers) FcCs||j_|j|jSr`)r rrr)rdrr3r3r4r s z FTPDataPortFactory.buildProtocolN)r/r0r1r2noisyrr3r3r3r4r} s rc@szeZdZdZdZdZddZddZdd Zd d Z d d Z ddZ ddZ dddZ ddZddZddZddZdS)FTPClientBasicz' Foundations of an FTP client. FrcCs<g|_d|_t|j|_|j|jg|_ d|_ dSr) actionQueuegreetingr rr _cb_greeting nextDeferredrOrEri_failedrhr3r3r4rb s  zFTPClientBasic.__init__cCs||dS)z8 Give an error to any queued deferreds. N_failrdrr3r3r4rE rzFTPClientBasic.failcCsn|jr|Sd|_|jr$z|jttd|Wn tjy#Ynw|jD] }| ttd|q'|S)z/ Errback all queued deferreds. rTzFTP connection lost) rrrrFailurerr AlreadyCalledErrorrrE)rdr ftpCommandr3r3r4r s  zFTPClientBasic._failcCrr`)r)rdrr3r3r4r rzFTPClientBasic._cb_greetingcCs4|durdSt|tr||j}tj||dS)z Sends a line, unless line is None. @param line: Line to send @type line: L{bytes} or L{unicode} N)r%rrrr LineReceiverrrr3r3r4r s   zFTPClientBasic.sendLinecCs|}|dur d|_dS|js#|jd|td|jd|_dS|jdkr-| ||j r8t d|j|j |_||jdS)zD (Private) Processes the next command in the queue. Nrg?PORTz<-- %s)popCommandQueuerrrinsertr rsendNextCommandrgeneratePortCommandrrrerrrdrr3r3r4r s  zFTPClientBasic.sendNextCommandcCsF|j|t|jdkr|jdur|jdur!|dSdSdSdS)a Add an FTPCommand object to the queue. If it's the only thing in the queue, and we are connected and we aren't waiting for a response of an earlier command, the command will be sent immediately. @param ftpCommand: an L{FTPCommand} rTN)rr=r rrrrr3r3r4 queueCommand s    zFTPClientBasic.queueCommandrTcCst||}|||jS)au Queues a string to be issued as an FTP command @param command: string of an FTP command to queue @param public: a flag intended for internal use by FTPClient. Don't change it unless you know what you're doing. @return: a L{Deferred} that will be called when the response to the command has been received. )rrr)rdrTrrr3r3r4queueStringCommand s z!FTPClientBasic.queueStringCommandcCs|jr |jdSdS)zR Return the front element of the command queue, or None if empty. rN)rr<rhr3r3r4r s zFTPClientBasic.popCommandQueuecsg}jd|dd}|||dur3td|dd|jfdd}|||D]}|j|dd q5dS) a  Login: send the username, send the password. If the password is L{None}, the PASS command won't be sent. Also, if the response to the USER command has a response code of 230 (User logged in), then PASS won't be sent either. zUSER rrNzPASS cs|ddr j|S)Nr230)r:rr)ri passwordCmdrdr3r4cancelPasswordIfNotNeeded" s z.cancelPasswordIfNotNeededcSrr`r3rr3r3r4r/ rz+FTPClientBasic.queueLogin..)rr=rrrrrOrE)rdrpr deferreds userDeferredrrr3rr4 queueLogin s      zFTPClientBasic.queueLogincCsttkr ||j}|jrtd||j|t d|}|s$dS|dd}|ddkr2dS|j durA| t |jdS|j}g|_|ddvrT|j |n%|ddvrf|j tt|ntd ||j tt||dS) zM (Private) Parses the response messages from the FTP server. z--> %sz\d{3} Nr1)23)45z"Server sent invalid response code )rrrJrrrrerir=rmatchrrErrrrrrrr)rdr codeIsValidrrir3r3r4rQ1 s.         zFTPClientBasic.lineReceivedcCs||dSr`rrr3r3r4ra rzFTPClientBasic.connectionLostN)rT)r/r0r1r2rrrbrErrrrrrrrrQrr3r3r3r4r s    $ 0rc@r) _PassiveConnectionFactoryFcCrr`) protoInstance)rdrr3r3r4rbh rz"_PassiveConnectionFactory.__init__cCs||j_|jSr`)rrrr3r3r4rk sz'_PassiveConnectionFactory.buildProtocolcCstd|}|jj|dS)NzConnection Failed)r}rrr)rdrrrPr3r3r4ro s z0_PassiveConnectionFactory.clientConnectionFailedN)r/r0r1rrbrrr3r3r3r4re s  rc@seZdZdZejZ d1ddZddZd d Z d d Z d dZ ddZ ddZ ddZd2ddZeZd2ddZeZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0S)3 FTPClientaI L{FTPClient} is a client implementation of the FTP protocol which exposes FTP commands as methods which return L{Deferred}s. Each command method returns a L{Deferred} which is called back when a successful response code (2xx or 3xx) is received from the server or which is error backed if an error response code (4xx or 5xx) is received from the server or if a protocol violation occurs. If an error response code is received, the L{Deferred} fires with a L{Failure} wrapping a L{CommandFailed} instance. The L{CommandFailed} instance is created with a list of the response lines received from the server. See U{RFC 959} for error code definitions. Both active and passive transfers are supported. @ivar passive: See description in __init__. rtwisted@twistedmatrix.comrTcCs t||||||_dS)ay Constructor. I will login as soon as I receive the welcome message from the server. @param username: FTP username @param password: FTP password @param passive: flag that controls if I use active or passive data connections. You can also change this after construction by assigning to C{self.passive}. N)rrbrpassive)rdrprrr3r3r4rb s   zFTPClient.__init__cCs|j||dS)zM Disconnect, and also give an error to any queued deferreds. N)rrrrr3r3r4rE s zFTPClient.failcCs$t|}t|t}|||S)a Retrieves a file or listing generated by the given command, feeding it to the given protocol. @param commands: list of strings of FTP commands to execute then receive the results of (e.g. C{LIST}, C{RETR}) @param protocol: A L{Protocol} B{instance} e.g. an L{FTPFileListProtocol}, or something that can be adapted to one. Typically this will be an L{IConsumer} implementation. @return: L{Deferred}. )r IProtocolrr r_openDataConnection)rdcommandsr wrapperr3r3r4receiveFromConnection s  zFTPClient.receiveFromConnectioncCs:t||||jddd}||j|dddS)zg Login: send the username, send the password, and set retrieval mode to binary zTYPE IrrcSrr`r3rr3r3r4r rz&FTPClient.queueLogin..N)rrrrOrE)rdrprrr3r3r4r s zFTPClient.queueLogincCst}|||}|j|fS)aQ XXX @return: A tuple of two L{Deferred}s: - L{Deferred} L{IFinishableConsumer}. You must call the C{finish} method on the IFinishableConsumer when the file is completely transferred. - L{Deferred} list of control-connection responses. )rrr)rdrrAr=r3r3r4sendToConnection s  zFTPClient.sendToConnectionc sJdd|D}tjdd|Dddd}|tjrZdgfdd}td }||j|j ||jjg}tj|ddd}|tfd d } | | n?td } j| _ | _ | j| j j | d d| _dd| _ || fdd|| j| j g}tj|ddd}|t|D]} | q|S)z5 This method returns a DeferredList. cSsg|]}t|ddqS)rTr)r)r6rTr3r3r4r$ rz1FTPClient._openDataConnection..cSsg|]}|jqSr3)r)r6r?r3r3r4r$ sT)fireOnOneErrback consumeErrorsNcs6t|ddd\}}t}|||d<dS)z5Connect to the port specified in the response to PASVrSrNr)rrconnectFactory)rirrr_mutabler rdr3r4 doPassive sz0FTPClient._openDataConnection..doPassiver cSs|do |d|S|Sr)r)rmr3r3r4r sz,FTPClient._openDataConnection..closercS|Sr`r3rBr3r3r4r rz/FTPClient._openDataConnection..cSrr`r3)rr3r3r4r rcSs||p|Sr`)rE)rPpcr3r3r4r s)r DeferredListrOrrrrrrrErrr rr) rdrr cmds cmdsDeferredr pasvCmdrrrportCmdr?r3r r4r s<           zFTPClient._openDataConnectioncCs\t}|j|_td|}||_|fdd}||_|jj}|j}dt |||_ dS)zG (Private) Generates the text of a given PORT command. rcSs|jr||Sr`)rr)rlistenerr3r3r4 listenerFail. sz3FTPClient.generatePortCommand..listenerFailzPORT N) rr r rrrErrrrr)rdrrrrrrr3r3r4r s    zFTPClient.generatePortCommandcCs |ddS)zK Returns a FTP escaped path (replace newlines with nulls).  r9)rXrVr3r3r4 escapePath: rzFTPClient.escapePathrcCs4d||g}|r|ddt||||S)a Retrieve a file from the given path This method issues the 'RETR' FTP command. The file is fed into the given Protocol instance. The data connection will be passive if self.passive is set. @param path: path to file that you wish to receive. @param protocol: a L{Protocol} instance. @param offset: offset to start downloading from @return: L{Deferred} zRETR rREST )rrrr)rdr?r offsetrr3r3r4 retrieveFileA s zFTPClient.retrieveFilecCs2d||g}|r|ddt|||S)a Store a file at the given path. This method issues the 'STOR' FTP command. @return: A tuple of two L{Deferred}s: - L{Deferred} L{IFinishableConsumer}. You must call the C{finish} method on the IFinishableConsumer when the file is completely transferred. - L{Deferred} list of control-connection responses. zSTOR rr)rrrr)rdr?rrr3r3r4 storeFileW s  zFTPClient.storeFilecspd|}d|}gtfddfdd}|j||S)a] Rename a file. This method issues the I{RNFR}/I{RNTO} command sequence to rename C{pathFrom} to C{pathTo}. @param pathFrom: the absolute path to the file to be renamed @type pathFrom: C{str} @param pathTo: the absolute path to rename the file to. @type pathTo: C{str} @return: A L{Deferred} which fires when the rename operation has succeeded or failed. If it succeeds, the L{Deferred} is called back with a two-tuple of lists. The first list contains the responses to the I{RNFR} command. The second list contains the responses to the I{RNTO} command. If either I{RNFR} or I{RNTO} fails, the L{Deferred} is errbacked with L{CommandFailed} or L{BadResponse}. @rtype: L{Deferred} @since: 8.2 zRNFR zRNTO cs|fSr`r3) toResponse) fromResponser3r4r rz"FTPClient.rename..cs|dSr`)rrr{)rCrdr3r4ebFrom sz FTPClient.rename..ebFrom)rrr rrrNrk chainDeferred)rdpathFrompathTo renameFromrenameTor r3)rrCrdr4r j s zFTPClient.renamecC$|durd}|d||g|S)a| Retrieve a file listing into the given protocol instance. This method issues the 'LIST' FTP command. @param path: path to get a file listing for. @param protocol: a L{Protocol} instance, probably a L{FTPFileListProtocol} instance. It can cope with most common file listing formats. @return: L{Deferred} Nr7zLIST rrrdr?r r3r3r4r s zFTPClient.listcCr&)a1 Retrieve a short file listing into the given protocol instance. This method issues the 'NLST' FTP command. NLST (should) return a list of filenames, one per line. @param path: path to get short file listing for. @param protocol: a L{Protocol} instance. Nr7zNLST r'r(r3r3r4nlst s zFTPClient.nlstcC|d||S)z Issues the CWD (Change Working Directory) command. @return: a L{Deferred} that will be called when done. zCWD rrrVr3r3r4r> sz FTPClient.cwdcCr*)a@ Make a directory This method issues the MKD command. @param path: The path to the directory to create. @type path: C{str} @return: A L{Deferred} which fires when the server responds. If the directory is created, the L{Deferred} is called back with the server response. If the server response indicates the directory was not created, the L{Deferred} is errbacked with a L{Failure} wrapping L{CommandFailed} or L{BadResponse}. @rtype: L{Deferred} @since: 8.2 zMKD r+rVr3r3r4r zFTPClient.makeDirectorycCr*)a^ Delete a file on the server. L{removeFile} issues a I{DELE} command to the server to remove the indicated file. Note that this command cannot remove a directory. @param path: The path to the file to delete. May be relative to the current dir. @type path: C{str} @return: A L{Deferred} which fires when the server responds. On error, it is errbacked with either L{CommandFailed} or L{BadResponse}. On success, it is called back with a list of response lines. @rtype: L{Deferred} @since: 8.2 zDELE r+rVr3r3r4r r,zFTPClient.removeFilecCr*)a` Delete a directory on the server. L{removeDirectory} issues a I{RMD} command to the server to remove the indicated directory. Described in RFC959. @param path: The path to the directory to delete. May be relative to the current working directory. @type path: C{str} @return: A L{Deferred} which fires when the server responds. On error, it is errbacked with either L{CommandFailed} or L{BadResponse}. On success, it is called back with a list of response lines. @rtype: L{Deferred} @since: 11.1 zRMD r+rVr3r3r4r r,zFTPClient.removeDirectorycCr)z Issues the CDUP (Change Directory UP) command. @return: a L{Deferred} that will be called when done. CDUPrrhr3r3r4cdup s zFTPClient.cdupcCr)ah Issues the PWD (Print Working Directory) command. The L{getDirectory} does the same job but automatically parses the result. @return: a L{Deferred} that will be called when done. It is up to the caller to interpret the response, but the L{parsePWDResponse} method in this module should work. PWDr.rhr3r3r4r1 s z FTPClient.pwdcCsdd}||S)a Returns the current remote directory. @return: a L{Deferred} that will be called back with a C{str} giving the remote directory or which will errback with L{CommandFailed} if an error response is returned. c Sspzt|dddddkrtWnttfy$tt|YSwt|d}|dur6tt|S|S)NrrHrTi)rr;rG IndexErrorrrrparsePWDResponse)rCr?r3r3r4cbParse s z'FTPClient.getDirectory..cbParse)r1r)rdr3r3r3r4 getDirectory s  zFTPClient.getDirectorycCr)z Issues the I{QUIT} command. @return: A L{Deferred} that fires when the server acknowledges the I{QUIT} command. The transport should not be disconnected until this L{Deferred} fires. rr.rhr3r3r4quit* s zFTPClient.quitN)rrrT)r)r/r0r1r2r rr rbrErrrrrrrretrrstorr rr)r>rrrr/r1r4r5r3r3r3r4rt s6  G#  0 rc@sJeZdZdZedZdZdZddZ ddZ d d Z d d Z d dZ dS)FTPFileListProtocola Parser for standard FTP file listings This is the evil required to match:: -rw-r--r-- 1 root other 531 Jan 29 03:26 README If you need different evil for a wacky FTP server, you can override either C{fileLinePattern} or C{parseDirectoryLine()}. It populates the instance attribute self.files, which is a list containing dicts with the following keys (examples from the above line): - filetype: e.g. 'd' for directories, or '-' for an ordinary file - perms: e.g. 'rw-r--r--' - nlinks: e.g. 1 - owner: e.g. 'root' - group: e.g. 'other' - size: e.g. 531 - date: e.g. 'Jan 29 03:26' - filename: e.g. 'README' - linktarget: e.g. 'some/file' Note that the 'date' value will be formatted differently depending on the date. Check U{http://cr.yp.to/ftp.html} if you really want to try to parse it. It also matches the following:: -rw-r--r-- 1 root other 531 Jan 29 03:26 I HAVE\ SPACE - filename: e.g. 'I HAVE SPACE' -rw-r--r-- 1 root other 531 Jan 29 03:26 LINK -> TARGET - filename: e.g. 'LINK' - linktarget: e.g. 'TARGET' -rw-r--r-- 1 root other 531 Jan 29 03:26 N S -> L S - filename: e.g. 'N S' - linktarget: e.g. 'L S' @ivar files: list of dicts describing the files in this listing z^(?P.)(?P.{9})\s+(?P\d*)\s*(?P\S+)\s+(?P\S+)\s+(?P\d+)\s+(?P...\s+\d+\s+[\d:]+)\s+(?P.{1,}?)( -> (?P[^\r]*))?\r?$ rcCs g|_dSr`)filesrhr3r3r4rbh rzFTPFileListProtocol.__init__cCsBttkr ||j}||}|dur||dS||dSr`)rrrJrparseDirectoryLine unknownLineaddFile)rdrrr3r3r4rQk s   z FTPFileListProtocol.lineReceivedcCst|j|}|dur dS|}|ddd|d<t|d|d<t|d|d<|dr8|ddd|d<|S)z Return a dictionary of fields, or None if line cannot be parsed. @param line: line of text expected to contain a directory entry @type line: str @return: dict Nfilenamez\ rHnlinksr linktarget)fileLinePatternr groupdictrXr)rdrrrr3r3r4r;t s z&FTPFileListProtocol.parseDirectoryLinecCs|j|dS)a Append file information dictionary to the list of known files. Subclasses can override or extend this method to handle file information differently without affecting the parsing of data from the server. @param info: dictionary containing the parsed representation of the file information @type info: dict N)r:r=)rdrr3r3r4r= s zFTPFileListProtocol.addFilecCr')a Deal with received lines which could not be parsed as file information. Subclasses can override this to perform any special processing needed. @param line: unparsable line as received @type line: str Nr3rr3r3r4r< s zFTPFileListProtocol.unknownLineN)r/r0r1r2rcompilerA delimiterrrbrQr;r=r<r3r3r3r4r85 s)  r8cCs td|}|r|dSdS)z Returns the path from a response to a PWD command. Responses typically look like:: 257 "/home/andrew" is current directory. For this example, I will return C{'/home/andrew'}. If I can't find the path, I return L{None}. z"(.*)"rN)rsearchgroups)rirr3r3r4r2 s  r2r`)r=)r2rCrUr rrrr4r1 ImportErrorzope.interfacerrtwistedr twisted.credrrrrxrrr r r r twisted.protocolsr rtwisted.pythonrrrRESTART_MARKER_REPLYSERVICE_READY_IN_N_MINUTESrrrrrCMD_NOT_IMPLMNTD_SUPERFLUOUSSYS_STATUS_OR_HELP_REPLYr  DIR_STATUSrHELP_MSGrSVC_READY_FOR_NEW_USERr,SVC_CLOSING_CTRL_CNXr DATA_CNX_OPEN_NO_XFR_IN_PROGRESSCLOSING_DATA_CNXrrENTERING_EPSV_MODErr~rrrrornNEED_ACCT_FOR_LOGINrSVC_NOT_AVAIL_CLOSING_CTRL_CNXrrrREQ_ACTN_ABRTD_FILE_UNAVAILREQ_ACTN_ABRTD_LOCAL_ERRREQ_ACTN_ABRTD_INSUFF_STORAGErurwryrrr{r_rNEED_ACCT_FOR_STORrkrprnrqr=rrrs PAGE_TYPE_UNKEXCEEDED_STORAGE_ALLOCFILENAME_NOT_ALLOWEDrfrar.rBrQrVrWr]r_rFrmrIrKrMrOrtrvrxrzr}rrrrr IConsumerrr ClientFactoryrr rrr TimeoutMixinrr!rrqr.r0r<rQrRr_rrIRealmrrrrrrrrrrrrrrr ServerFactoryrrrrr8r2r3r3r3r4s         !#$%'(*+.023457:;<=>?@ABCDEFQ  !    c O, 8tU"%  ,VD p