VirtualBox

Changeset 53242 in vbox


Ignore:
Timestamp:
Nov 5, 2014 4:28:08 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96793
Message:

Main/HostDnsService: Tcpip\Parameters\NameServer value is not updated
when the list of name servers is statically configured, so don't
inspect NameServer and DhcpNameServer directly - instead use
DnsQueryConfig(DnsConfigDnsServerList, ...) from DnsAPI.dll

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r52769 r53242  
    328328        socket \
    329329        $(LIB_VMM)
     330
     331VBoxSVC_LIBS.win += \
     332        $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/dnsapi.lib
    330333
    331334VBoxSVC_INTERMEDIATES = \
  • trunk/src/VBox/Main/src-server/win/HostDnsServiceWin.cpp

    r53165 r53242  
    2525
    2626#include <Windows.h>
     27#include <windns.h>
    2728
    2829#include <algorithm>
     
    202203    LONG lrc;
    203204
    204     std::string strNameServer;
    205205    std::string strDomain;
    206     std::string strDhcpNameServer;
    207206    std::string strDhcpDomain;
    208207    std::string strSearchList;  /* NB: comma separated, no spaces */
     
    237236            --cbKeyData;     /* don't count trailing NUL if present */
    238237
    239         if (RTStrICmp("NameServer", keyName) == 0)
    240         {
    241             strNameServer.assign(keyData, cbKeyData);
    242             Log2(("... NameServer=\"%s\"\n", strNameServer.c_str()));
    243         }
    244         else if (RTStrICmp("Domain", keyName) == 0)
     238        if (RTStrICmp("Domain", keyName) == 0)
    245239        {
    246240            strDomain.assign(keyData, cbKeyData);
    247241            Log2(("... Domain=\"%s\"\n", strDomain.c_str()));
    248242        }
    249         else if (RTStrICmp("DhcpNameServer", keyName) == 0)
    250         {
    251             strDhcpNameServer.assign(keyData, cbKeyData);
    252             Log2(("... DhcpNameServer=\"%s\"\n", strDhcpNameServer.c_str()));
    253         }
    254243        else if (RTStrICmp("DhcpDomain", keyName) == 0)
    255244        {
     
    266255    HostDnsInformation info;
    267256
    268     if (!strNameServer.empty())
    269         vappend(info.servers, strNameServer);
    270     else if (!strDhcpNameServer.empty())
    271         vappend(info.servers, strDhcpNameServer);
     257    /*
     258     * When name servers are configured statically it seems that the
     259     * value of Tcpip\Parameters\NameServer is NOT set, inly interface
     260     * specific NameServer value is (which triggers notification for
     261     * us to pick up the change).  Fortunately, DnsApi seems to do the
     262     * right thing there.
     263     */
     264    DNS_STATUS status;
     265    PIP4_ARRAY pIp4Array = NULL;
     266
     267    // NB: must be set on input it seems, despite docs' claim to the contrary.
     268    DWORD cbBuffer = sizeof(&pIp4Array);
     269
     270    status = DnsQueryConfig(DnsConfigDnsServerList,
     271                            DNS_CONFIG_FLAG_ALLOC, NULL, NULL,
     272                            &pIp4Array, &cbBuffer);
     273   
     274    if (status == NO_ERROR && pIp4Array != NULL)
     275    {
     276        for (DWORD i = 0; i < pIp4Array->AddrCount; ++i)
     277        {
     278            char szAddrStr[16] = "";
     279            RTStrPrintf(szAddrStr, sizeof(szAddrStr), "%RTnaipv4", pIp4Array->AddrArray[i]);
     280
     281            Log2(("  server %d: %s\n", i+1,  szAddrStr));
     282            info.servers.push_back(szAddrStr);
     283        }
     284
     285        LocalFree(pIp4Array);
     286    }
    272287
    273288    if (!strDomain.empty())
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