]> git.saurik.com Git - apple/security.git/blobdiff - Network/ftp-protocol.cpp
Security-54.1.tar.gz
[apple/security.git] / Network / ftp-protocol.cpp
index 9e2a87fc14b7c6a216cb48b054ecb2bffded191a..ae94568247cf1d5ee6c6b0a0f276f2b55732d8e9 100644 (file)
 // Only stream mode is supported.
 // No EBCDIC support.
 //
+#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacErrors.h>
+
 #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<FTPConnection>().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: