Resolving localhost on Windows 7 (for exim)

Pierre A. Humblet Pierre.Humblet@ieee.org
Mon Jan 5 14:04:00 GMT 2015


While porting exim to Windows 64 I have observed strange results when 
resolving localhost

On Windows XP,

Resolv: search "localhost" type 28
Resolv: query "localhost" type 28
Resolv: DnsQuery: 0 (Windows)
Resolv: localhost Section 0 Type 28 Windows Record Length 16
08:02:06  3760 DNS lookup of localhost (AAAA) succeeded
Resolv: search "localhost" type 1
Resolv: query "localhost" type 1
Resolv: DnsQuery: 0 (Windows)
Resolv: localhost Section 1 Type 1 Windows Record Length 4
08:44:13  5552 DNS lookup of localhost (A) succeeded

We see that for IPV4 localhost things are fine.
Windows returns an answer section (1) and Cygwin processes it correctly.

However for IPV6 it returned a question section (0) but with data in it.
Cygwin essentially drops that.
That's why above the application tried an A record after getting the 
AAAA record, which was empty.


However of Windows 7
CYGWIN_NT-6.1 Dell3020 1.7.33-2(0.280/5/3) 2014-11-13 15:47 x86_64 Cygwin

Resolv: search "localhost" type 28
Resolv: query "localhost" type 28
Resolv: DnsQuery: 0 (Windows)
Resolv: localhost Section 0 Type 28 Windows Record Length 16
08:22:24 140244 DNS lookup of localhost (AAAA) succeeded
Resolv: search "localhost" type 1
Resolv: query "localhost" type 1
Resolv: DnsQuery: 0 (Windows)
Resolv: localhost Section 0 Type 1 Windows Record Length 4

We see that Windows returns question sections in both cases and 
localhost is never resolved.
 From what I have seen Windows never returns question section in 
normal cases so I suggest
inserting the following on line 251 of minires-os-if.c, to 
essentially turn question sections
in answer sections (after  while (rr) { )

if ((rr->Flags.DW & 0x3) == 0) {
         DPRINTF(debug, "Got section 0 %s %d with data length %d\n", 
DomName, Type, rr->wDataLength);
         if (rr->wDataLength > 0)
                 rr->Flags.DW |= 1; // Make it an answer section as 
there is data
}
It would be nice if this would be tried ASAP.
However I am not setup currently to build cygwin.


Occasionally I also see localhost queries fail.
I have not been able to pinpoint what causes that.

Resolv: search "localhost" type 28
Resolv: query "localhost" type 28
Resolv: DnsQuery: 9003 (Windows)
08:00:14 145640 DNS lookup of localhost (AAAA) gave HOST_NOT_FOUND
08:00:14 145640 returning DNS_NOMATCH
Resolv: search "localhost" type 1
Resolv: query "localhost" type 1
Resolv: DnsQuery: 9003 (Windows)


In light of RFC 6761 we should handle localhost in gethostbyname2, 
for both IP4 and IP6
While we are at it we should also handle numerical domains w.x.y.z there.
That's less urgent, I can do that in the coming weeks.
I
Pierre



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list