> -----Original Message----- > From: Corinna Vinschen > Sent: Thursday, January 08, 2015 08:24 > > Hi Pierre, > > On Jan 5 09:03, Pierre A. Humblet wrote: > > 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 } > > Can you please send at least a real patch? Without the formatting matching > the surrounding code I'm totally unsure where to apply this code. A > ChangeLog entry would be helpful as well.
Here they are. cvs diff -up minires-os-if.c Index: minires-os-if.c =================================================================== RCS file: /cvs/src/src/winsup/cygwin/libc/minires-os-if.c,v retrieving revision 1.15 diff -u -p -r1.15 minires-os-if.c --- minires-os-if.c 23 Apr 2013 09:44:35 -0000 1.15 +++ minires-os-if.c 12 Jan 2015 03:39:27 -0000 @@ -249,6 +249,13 @@ static int cygwin_query(res_state statp, rr = pQueryResultsSet; section = 0; while (rr) { + /* Some Windows versions return questions when providing locally + generated answers, for example for "localhost" or for the computer name */ + if (((rr->Flags.DW & 0x3) == DnsSectionQuestion) && + (rr->wDataLength > 0)) { + DPRINTF(debug, "Changing record below from question to answer\n"); + rr->Flags.DW ^= DnsSectionQuestion ^ DnsSectionAnswer; + } if (!counts[0] && (rr->Flags.DW & 0x3)) { /* No question. Adopt the first name as the name in the question */ if ((len = dn_comp(rr->pName, ptr, AnsLength - 4, 2015-01-11 Pierre A. Humblet <pie...@phumblet.no-ip.org> * minires-os-if.c (cygwin_query): Change questions into answers. > > It would be nice if this would be tried ASAP. > > However I am not setup currently to build cygwin. > > It's not exactly tricky to set this up... Right, I had it all downloaded and working in one evening. CYGWIN_NT-6.1 Dell3020 1.7.34(0.283/5/3) 2015-01-11 18:48 x86_64 Cygwin With the above changes localhost is resolved fine. Now the bad news: the exim daemon crashes. The reason is this: $ getent passwd exim NT SERVICE+exim:*:376394:376394:U-NT SERVICE\exim,S-1-5-80-3213360373-4072665756-2198108471-1641386292-839958090:/:/sbin/nologin So even though I am requesting just "exim" I am getting an entry for "NT SERVICE+exim" Talk about aliasing. The way the exim code works, when an "exim" user exists (per getpwnam) the daemon setuids to it. Here it's trying to setuid to a service. This would break every exim installation. 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