X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=E6kGBvtyeTNyNVDTl8aMgmJQH5zm+oG/noi1mbaRfUC udm7abghV9fQejnqzCo0PBCOk8fz9HkOSt22jWQWsO+3xVHCVQ6Xs2A713VJznSb c0Iz597q2+3h+9XDGU/nItlms3gimX71S+lLQ9UU8CSs0RJw9ifgfKM9ykeJ5P/0 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=aYf4R8KJpykcLenwroY2GucAEPQ=; b=hj8x3TPEwY+KsAn3c xK5bnjHoIcxTW7L1FlDQmKxRjH7ZsbsdwYSLdNexHmfZavAc+yU7gvLctqvnOWC5 vHZy6P85OxSc7pOD3psDIypS4ZKzxig511tl1XKkg/SDBFGVYiiiwjS3jFdkHmX9 KTQa6XxVBeIZiOTSTlrZ+pbrWI= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: vms173025pub.verizon.net X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=D9vw8UVm c=1 sm=1 tr=0 a=++QE0vWJ+/OcbE0B+pKMCw==:117 a=qpBMU8TwT7QA:10 a=IkcTkHD0fZMA:10 a=o83nqyVRAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=YNv0rlydsVwA:10 a=4RoUMAPcAAAA:8 a=GCnZSIUojJ7hjhusl_UA:9 a=69mlEnWZ7Sn9z5j1:21 a=jpy-Jr-SUniox_e4:21 a=QEXdDO2ut3YA:10 From: "Pierre A. Humblet" To: References: <0NHP009ITJ361TD0 AT vms173009 DOT mailsrvcs DOT net> <20150108132353 DOT GN4190 AT calimero DOT vinschen DOT de> In-reply-to: <20150108132353.GN4190@calimero.vinschen.de> Subject: RE: Resolving localhost on Windows 7 (for exim) Date: Mon, 12 Jan 2015 11:16:16 -0500 Message-id: <003d01d02e83$1aaaf7b0$5000e710$@ieee.org> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id t0CGH9Sv027845 > -----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 * 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