VirtualBox

Changeset 82781 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jan 16, 2020 12:49:33 PM (5 years ago)
Author:
vboxsync
Message:

IPRT/FTP: Implemented FEAT and OPTS commands, along with some more protocol tweaking in order to make connecting w/ Nautilus work. bugref:9646

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/ftp-server.cpp

    r82773 r82781  
    133133    /** Gets the current working directory. */
    134134    RTFTPSERVER_CMD_PWD,
     135    /** Get options. Needed in conjunction with the FEAT command. */
     136    RTFTPSERVER_CMD_OPTS,
    135137    /** Terminates the session (connection). */
    136138    RTFTPSERVER_CMD_QUIT,
     
    300302static FNRTFTPSERVERCMD rtFtpServerHandlePORT;
    301303static FNRTFTPSERVERCMD rtFtpServerHandlePWD;
     304static FNRTFTPSERVERCMD rtFtpServerHandleOPTS;
    302305static FNRTFTPSERVERCMD rtFtpServerHandleQUIT;
    303306static FNRTFTPSERVERCMD rtFtpServerHandleRETR;
     
    334337    { RTFTPSERVER_CMD_CDUP,     "CDUP", true,  rtFtpServerHandleCDUP },
    335338    { RTFTPSERVER_CMD_CWD,      "CWD",  true,  rtFtpServerHandleCWD  },
    336     { RTFTPSERVER_CMD_FEAT,     "FEAT", true, rtFtpServerHandleFEAT },
     339    { RTFTPSERVER_CMD_FEAT,     "FEAT", false, rtFtpServerHandleFEAT },
    337340    { RTFTPSERVER_CMD_LIST,     "LIST", true,  rtFtpServerHandleLIST },
    338341    { RTFTPSERVER_CMD_MODE,     "MODE", true,  rtFtpServerHandleMODE },
     
    341344    { RTFTPSERVER_CMD_PORT,     "PORT", true,  rtFtpServerHandlePORT },
    342345    { RTFTPSERVER_CMD_PWD,      "PWD",  true,  rtFtpServerHandlePWD  },
     346    { RTFTPSERVER_CMD_OPTS,     "OPTS", false, rtFtpServerHandleOPTS },
    343347    { RTFTPSERVER_CMD_QUIT,     "QUIT", false, rtFtpServerHandleQUIT },
    344348    { RTFTPSERVER_CMD_RETR,     "RETR", true,  rtFtpServerHandleRETR },
     
    352356};
    353357
    354 /** Feature string which represents all commands we support in addition to RFC 959.
     358/** Feature string which represents all commands we support in addition to RFC 959 (see RFC 2398).
    355359 *  Must match the command table above.
    356360 *
    357  *  Don't forget the terminating ";" at each feature. */
     361 *  Don't forget the beginning space (" ") at each feature. */
    358362#define RTFTPSERVER_FEATURES_STRING \
    359     "SIZE;" /* Supports reporting file sizes. */
     363    " SIZE\r\n" \
     364    " UTF8"
    360365
    361366
     
    380385    LogFlowFunc(("Sending reply code %RU32\n", enmReply));
    381386
    382     return RTTcpWrite(pClient->hSocket, szReply, strlen(szReply) + 1);
     387    return RTTcpWrite(pClient->hSocket, szReply, strlen(szReply));
    383388}
    384389
     
    423428    RTStrFree(pszFmt);
    424429
    425     rc = RTTcpWrite(pClient->hSocket, pszMsg, strlen(pszMsg) + 1 /* Include termination */);
     430    rc = RTTcpWrite(pClient->hSocket, pszMsg, strlen(pszMsg));
    426431
    427432    RTStrFree(pszMsg);
     
    450455    AssertRCReturn(rc, rc);
    451456
    452     rc = RTTcpWrite(pClient->hSocket, psz, strlen(psz) + 1 /* Include termination */);
     457    LogFlowFunc(("Sending reply '%s'\n", psz));
     458
     459    rc = RTTcpWrite(pClient->hSocket, psz, strlen(psz));
    453460
    454461    RTStrFree(psz);
     
    10551062    RT_NOREF(cArgs, apcszArgs);
    10561063
    1057     int rc = rtFtpServerSendReplyRc(pClient, RTFTPSERVER_REPLY_SYSTEM_STATUS); /* Features begin */
     1064    int rc = rtFtpServerSendReplyStr(pClient, "211-BEGIN Features:");
    10581065    if (RT_SUCCESS(rc))
    10591066    {
    10601067        rc = rtFtpServerSendReplyStr(pClient, RTFTPSERVER_FEATURES_STRING);
    10611068        if (RT_SUCCESS(rc))
    1062             rc = rtFtpServerSendReplyRc(pClient, RTFTPSERVER_REPLY_SYSTEM_STATUS); /* Features end */
     1069            rc = rtFtpServerSendReplyStr(pClient, "211 END Features");
    10631070    }
    10641071
     
    12421249    if (RT_SUCCESS(rc))
    12431250       rc = rtFtpServerSendReplyRcEx(pClient, RTFTPSERVER_REPLY_PATHNAME_OK, "\"%s\"", szPWD); /* See RFC 959, APPENDIX II. */
     1251
     1252    return rc;
     1253}
     1254
     1255static int rtFtpServerHandleOPTS(PRTFTPSERVERCLIENT pClient, uint8_t cArgs, const char * const *apcszArgs)
     1256{
     1257    RT_NOREF(cArgs, apcszArgs);
     1258
     1259    int rc = VINF_SUCCESS;
     1260
     1261    int rc2 = rtFtpServerSendReplyRc(pClient, RTFTPSERVER_REPLY_OKAY);
     1262    if (RT_SUCCESS(rc))
     1263        rc = rc2;
    12441264
    12451265    return rc;
     
    13941414    int rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szOSInfo, sizeof(szOSInfo));
    13951415    if (RT_SUCCESS(rc))
    1396         rc = rtFtpServerSendReplyStr(pClient, szOSInfo);
     1416        rc = rtFtpServerSendReplyStr(pClient, "215 %s", szOSInfo);
    13971417
    13981418    return rc;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette