X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/bac41a7b9a0a9254fa30f8bb6e6038ab71a483e2..67c7378dcb8de24c86b7fedff90b4b496f2e474c:/Network/ftp-protocol.cpp diff --git a/Network/ftp-protocol.cpp b/Network/ftp-protocol.cpp index 9e2a87fc..ae945682 100644 --- a/Network/ftp-protocol.cpp +++ b/Network/ftp-protocol.cpp @@ -40,10 +40,11 @@ // Only stream mode is supported. // No EBCDIC support. // +#include + #include "ftp-protocol.h" #include "netparameters.h" - namespace Security { namespace Network { @@ -104,6 +105,10 @@ void FTPProtocol::FTPConnection::startCommand() printfe("RMD %s", mOperationPath.c_str()); state = directCommandSent; return; + case removeFile: + printfe("DELE %s", mOperationPath.c_str()); + state = directCommandSent; + return; case genericCommand: printfe("%s", mOperationPath.c_str()); state = directCommandSent; @@ -327,8 +332,12 @@ void FTPProtocol::FTPConnection::transit(Event event, char *input, size_t length case transferSent: switch (reply) { case 150: + case 125: + transfer().ftpResponse() = input; // remember response for caller. + transfer().ftpResponseCode() = reply; if (!mPassive) mReceiver.receive(mDataPath); // accept incoming connection and stop listening + observe(Observer::resultCodeReady, input); // engage the data path switch (operation()) { @@ -336,9 +345,11 @@ void FTPProtocol::FTPConnection::transit(Event event, char *input, size_t length case downloadDirectory: case downloadListing: mDataPath.start(sink()); + observe(Observer::downloading, input); break; case upload: mDataPath.start(source()); + observe(Observer::uploading, input); break; default: assert(false); @@ -361,7 +372,9 @@ void FTPProtocol::FTPConnection::transit(Event event, char *input, size_t length mDataPath.connectionDone(); break; case 452: - fail(input, ENOSPC); + mDataPath.close(); + state = idle; + fail(input, dskFulErr); break; default: // transfer failed // (ignore any error in mDataPath - prefer diagnostics from remote) @@ -509,6 +522,7 @@ void FTPProtocol::FTPTransfer::start() void FTPProtocol::FTPTransfer::abort() { + observe(Observer::aborting); setError("aborted"); connectionAs().abort(); } @@ -529,7 +543,9 @@ Transfer::ResultClass FTPProtocol::FTPTransfer::resultClass() const InetReply reply(errorDescription().c_str()); if (reply / 10 == 53) // 53x - authentication failure return authorizationFailure; - // when in doubt, blame the remote + if (errorDescription() == "aborted") + return abortedFailure; + // when in doubt, blame the remote return remoteFailure; } case finished: