VirtualBox

Ignore:
Timestamp:
Feb 3, 2021 11:28:21 PM (4 years ago)
Author:
vboxsync
Message:

NAT/Net: Create network's own release log file only after we have
verified the network of that name actually exists. bugref:9929.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r87549 r87596  
    162162    virtual ~VBoxNetLwipNAT();
    163163
    164     static int logInit(int argc, char **argv);
    165 
    166164    virtual void usage() { /** @todo should be implemented */ };
    167165    virtual int parseOpt(int c, const RTGETOPTUNION &Value);
     
    173171
    174172private:
     173    int logInit();
     174
    175175    static void reportError(const char *a_pcszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
    176176
     
    327327        return rc;
    328328
     329    /*
     330     * We get the network name on the command line.  Get hold of our
     331     * API object.
     332     */
    329333    const std::string &networkName = getNetworkName();
    330334    hrc = virtualbox->FindNATNetworkByName(com::Bstr(networkName.c_str()).raw(),
     
    335339        return VERR_NOT_FOUND;
    336340    }
     341
     342    /*
     343     * Now that we know the network name we can create the release log file.
     344     */
     345    logInit();
    337346
    338347
     
    14551464 */
    14561465/* static */
    1457 int VBoxNetLwipNAT::logInit(int argc, char **argv)
     1466int VBoxNetLwipNAT::logInit()
    14581467{
    14591468    size_t cch;
     
    14711480        return rc;
    14721481
    1473     const char *pcszNetwork = NULL;
    1474 
    1475     // XXX: This duplicates information from VBoxNetBaseService.cpp.
    1476     // Perhaps option definitions should be exported as public static
    1477     // member of VBoxNetBaseService?
    1478     static const RTGETOPTDEF s_aOptions[] = {
    1479         { "--network", 'n', RTGETOPT_REQ_STRING }
    1480     };
    1481 
    1482     RTGETOPTSTATE GetState;
    1483     RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1,
    1484                  RTGETOPTINIT_FLAGS_NO_STD_OPTS);
    1485 
    1486     RTGETOPTUNION ValueUnion;
    1487     int ch;
    1488     while ((ch = RTGetOpt(&GetState, &ValueUnion)))
    1489     {
    1490         if (ch == 'n')
    1491         {
    1492             pcszNetwork = ValueUnion.psz;
    1493             break;
    1494         }
    1495     }
    1496 
    1497     if (pcszNetwork == NULL)
     1482    const std::string &strNetworkName = getNetworkName();
     1483    if (strNetworkName.empty())
    14981484        return VERR_MISSING;
    14991485
    15001486    char szNetwork[RTPATH_MAX];
    1501     rc = RTStrCopy(szNetwork, sizeof(szNetwork), pcszNetwork);
     1487    rc = RTStrCopy(szNetwork, sizeof(szNetwork), strNetworkName.c_str());
    15021488    if (RT_FAILURE(rc))
    15031489        return rc;
     
    15961582#endif
    15971583
    1598     VBoxNetLwipNAT::logInit(argc, argv);
    1599 
    16001584    hrc = com::Initialize();
    16011585    if (FAILED(hrc))
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