Changeset 87601 in vbox for trunk/src/VBox/NetworkServices/NAT
- Timestamp:
- Feb 4, 2021 12:47:38 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142635
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r87599 r87601 131 131 friend class NATNetworkListener; 132 132 133 /** Home folder location; used as default directory for several paths. */ 134 com::Utf8Str m_strHome; 135 133 136 struct proxy_options m_ProxyOptions; 134 137 struct sockaddr_in m_src4; … … 172 175 private: 173 176 int comInit(); 177 int homeInit(); 174 178 int logInit(); 175 179 … … 328 332 return rc; 329 333 334 /* Get the home folder location. It's ok if it fails. */ 335 homeInit(); 336 330 337 /* 331 338 * We get the network name on the command line. Get hold of its … … 474 481 } 475 482 476 com::Bstr bstr; 477 hrc = virtualbox->COMGETTER(HomeFolder)(bstr.asOutParam()); 478 AssertComRCReturn(hrc, VERR_NOT_FOUND); 479 if (!bstr.isEmpty()) 480 { 481 com::Utf8Str strTftpRoot(com::Utf8StrFmt("%ls%c%s", 482 bstr.raw(), RTPATH_DELIMITER, "TFTP")); 483 484 if (m_strHome.isNotEmpty()) 485 { 486 com::Utf8Str strTftpRoot(com::Utf8StrFmt("%s%c%s", 487 m_strHome.c_str(), RTPATH_DELIMITER, "TFTP")); 483 488 char *pszStrTemp; // avoid const char ** vs char ** 484 489 rc = RTStrUtf8ToCurrentCP(&pszStrTemp, strTftpRoot.c_str()); … … 556 561 557 562 return VINF_SUCCESS; 563 } 564 565 566 /** 567 * Get the VirtualBox home folder. 568 * 569 * It is used as the base directory for the default release log file 570 * and for the TFTP root location. 571 */ 572 int VBoxNetLwipNAT::homeInit() 573 { 574 HRESULT hrc; 575 int rc; 576 577 com::Bstr bstrHome; 578 hrc = virtualbox->COMGETTER(HomeFolder)(bstrHome.asOutParam()); 579 if (SUCCEEDED(hrc)) 580 { 581 m_strHome = bstrHome; 582 return VINF_SUCCESS; 583 } 584 585 /* 586 * In the unlikely event that we have failed to retrieve 587 * HomeFolder via the API, try the fallback method. Note that 588 * despite "com" namespace it does not use COM. 589 */ 590 char szHome[RTPATH_MAX] = ""; 591 rc = com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome), false); 592 if (RT_SUCCESS(rc)) 593 { 594 m_strHome = szHome; 595 return VINF_SUCCESS; 596 } 597 598 return rc; 558 599 } 559 600 … … 1526 1567 int rc; 1527 1568 1528 /*1529 * NB: Contrary to what the "com" namespace might suggest, both1530 * this call, and the call below to create the release logger are1531 * NOT actually COM related in any way and can be used before COM1532 * is initialized.1533 */1534 char szHome[RTPATH_MAX];1535 rc = com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome), false);1536 if (RT_FAILURE(rc))1537 return rc;1538 1539 1569 const std::string &strNetworkName = getNetworkName(); 1540 1570 if (strNetworkName.empty()) … … 1553 1583 } 1554 1584 1585 const char *pcszLogFile = NULL; 1555 1586 char szLogFile[RTPATH_MAX]; 1556 cch = RTStrPrintf(szLogFile, sizeof(szLogFile), 1557 "%s%c%s.log", szHome, RTPATH_DELIMITER, szNetwork); 1558 if (cch >= sizeof(szLogFile)) 1559 { 1560 return VERR_BUFFER_OVERFLOW; 1587 if (m_strHome.isNotEmpty()) 1588 { 1589 cch = RTStrPrintf(szLogFile, sizeof(szLogFile), 1590 "%s%c%s.log", m_strHome.c_str(), RTPATH_DELIMITER, szNetwork); 1591 if (cch < sizeof(szLogFile)) 1592 pcszLogFile = szLogFile; 1561 1593 } 1562 1594 … … 1574 1606 1575 1607 char szEnvVarBase[128]; 1608 const char *pcszEnvVarBase = szEnvVarBase; 1576 1609 cch = RTStrPrintf(szEnvVarBase, sizeof(szEnvVarBase), 1577 1610 "VBOXNET_%s_RELEASE_LOG", szNetwork); 1578 1611 if (cch >= sizeof(szEnvVarBase)) 1579 return VERR_BUFFER_OVERFLOW;1612 pcszEnvVarBase = NULL; 1580 1613 1581 1614 rc = com::VBoxLogRelCreate("NAT Network", 1582 szLogFile,1615 pcszLogFile, 1583 1616 RTLOGFLAGS_PREFIX_TIME_PROG, 1584 1617 "all all.restrict -default.restrict", 1585 szEnvVarBase,1618 pcszEnvVarBase, 1586 1619 RTLOGDEST_FILE, 1587 1620 32768 /* cMaxEntriesPerGroup */,
Note:
See TracChangeset
for help on using the changeset viewer.