Changeset 82735 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jan 14, 2020 12:59:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/ftp-server.cpp
r82734 r82735 357 357 RTStrPrintf2(szReply, sizeof(szReply), "%RU32\r\n", enmReply); 358 358 359 LogFlowFunc(("Sending reply code %RU32\n", enmReply)); 360 359 361 return RTTcpWrite(pClient->hSocket, szReply, strlen(szReply) + 1); 362 } 363 364 /** 365 * Replies a (three digit) reply code with a custom message back to the client. 366 * 367 * @returns VBox status code. 368 * @param pClient Client to reply to. 369 * @param enmReply Reply code to send. 370 * @param pcszFormat Format string of message to send with the reply code. 371 */ 372 static int rtFtpServerSendReplyRcEx(PRTFTPSERVERCLIENT pClient, RTFTPSERVER_REPLY enmReply, 373 const char *pcszFormat, ...) 374 { 375 char *pszMsg = NULL; 376 377 va_list args; 378 va_start(args, pcszFormat); 379 char *pszFmt = NULL; 380 const int cch = RTStrAPrintfV(&pszFmt, pcszFormat, args); 381 va_end(args); 382 AssertReturn(cch > 0, VERR_NO_MEMORY); 383 384 int rc = RTStrAPrintf(&pszMsg, "%RU32", enmReply); 385 AssertRCReturn(rc, rc); 386 387 if (pszFmt) 388 { 389 rc = RTStrAAppend(&pszMsg, " - "); 390 AssertRCReturn(rc, rc); 391 392 rc = RTStrAAppend(&pszMsg, pszFmt); 393 AssertRCReturn(rc, rc); 394 } 395 396 397 rc = RTStrAAppend(&pszMsg, "\r\n"); 398 AssertRCReturn(rc, rc); 399 400 RTStrFree(pszFmt); 401 402 rc = RTTcpWrite(pClient->hSocket, pszMsg, strlen(pszMsg) + 1 /* Include termination */); 403 404 RTStrFree(pszMsg); 405 406 return rc; 360 407 } 361 408 … … 1211 1258 && cArgs) /* At least the actual command (without args) must be present. */ 1212 1259 { 1260 LogFlowFunc(("Handling command '%s'\n", papszArgs[0])); 1261 1213 1262 unsigned i = 0; 1214 1263 for (; i < RT_ELEMENTS(g_aCmdMap); i++) … … 1232 1281 rc = rc2; 1233 1282 1283 LogFlowFunc(("Command not implemented\n", papszArgs[0])); 1234 1284 return rc; 1235 1285 } … … 1371 1421 Client.hSocket = hSocket; 1372 1422 1423 LogFlowFunc(("New client connected\n")); 1424 1373 1425 rtFtpServerClientStateReset(&Client.State); 1374 1426 1375 /* Send welcome message. */ 1376 int rc = rtFtpServerSendReplyRc(&Client, RTFTPSERVER_REPLY_READY_FOR_NEW_USER); 1427 /* 1428 * Send welcome message. 1429 * Note: Some clients (like FileZilla / Firefox) expect a message together with the reply code, 1430 * so make sure to include at least *something*. 1431 */ 1432 int rc = rtFtpServerSendReplyRcEx(&Client, RTFTPSERVER_REPLY_READY_FOR_NEW_USER, 1433 "Welcome!"); 1377 1434 if (RT_SUCCESS(rc)) 1378 1435 {
Note:
See TracChangeset
for help on using the changeset viewer.