X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBF63386182E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1707953335;
	bh=Bc2Z5Z6oijhVY+6Xc9biAbSyCqRnKIXaHCFKQeVEegc=;
	h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:
	 List-Help:List-Subscribe:From:Reply-To:Cc:From;
	b=p04+U8kdFvYWVT3OSIgAQyCTb1QrKiyEj14H6VgxkizzvFA2OrSsfkb5JxIynr7YU
	 up9gIabUQqOj+ba4jhMwHdHa7LdE4x1vjoP84Q8/vRGz17AJX2uWCyWdrI2fYpHReB
	 5/W3EurgnCquYTLXHJsVagXLZPJD593J8Vjlmlm8=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E286A3857716
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E286A3857716
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707953312; cv=none;
 b=OJ+bshcovBJ34pqANnzmc+GRwBRD6UIL23dLs6jsdrdn++PGfegVckwkD12I+hiSwnsl61mDbmH0zoW6xuEM2zyRx+JCM3mWMwwmiteslp8Bb+cuq2mIH7QfNXCJmEfR9ocT+fhbUHtl5Bdd95Ny+IdeUsYcmxuHIw4VDQH9Nkw=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1707953312; c=relaxed/simple;
 bh=P0hshJVY+I81Gr0ymBz677hDS4EsEpxmmcyPe1OrA2Y=;
 h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject;
 b=sLaYsplihHo44NJqUYYVsYzNs83WOYvn1m5394EXXq8mk25yDOUtqQXMuQMT29atiu9jwhwtNxP8VPwVZgjl69YNSrd8YHmLL1TlBPgnqqpyrO4S+E4yMGbd4oCMYmSkc37K5lRwkn1nsg7QNkZhJeNIoKAYgXas6VEWQ1UMcnA=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <00209ed4-b4a3-4125-9a8a-32ea0fcefc7d@jhmg.net>
Date: Wed, 14 Feb 2024 15:28:28 -0800
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
To: cygwin@cygwin.com
Subject: Win 11 Cygwin dns-utils "dig" and "host": Option -6 causes command to
 timeout
Autocrypt: addr=jhg@jhmg.net; keydata=
 xsDiBDWEWocRBADfF9Q6lhkW9USReZ96cBC93kq3bblkNslVAZzm9itW7sAEzHbydIZ9hZjm
 e93UxUPzg1zGXX9xrdQy0+lHxkj2wvzgEF50Kqjft6KAd8AqiNmcbu5Q+/SHIP87C/tD/wWO
 TX7I99ekggy+5a6illN/s7MhuPIsMtt3ofFFcuOvswCg/08V11KALulG6u9j1affyHy20UMD
 /A1MRT3YZt6NJE9XbcalVLQzWc+ArCkW0oxNs/wrQ26lYoWuj20nusq9MDkuOL1h1FxeUrgx
 kKP+1zyYaQkB2lbJyvGvIpXgxY4vUnOXwMovTcRST3bWOOSIiYVOzKWJh5fPtoEaU5wFZ6yU
 lu/QGoS8Lt9QOI/XjjRaJjf0T6rKBADTn4xcxNIQNWSxJthmH3ipn39+sizwkZHfmAVHUf6w
 f4cDJ8mA3jl0RWKTnxj+5zEY32VduewHtNUtgwugXaIlLM/ErO+tzxQ4R6QysucgxmJBUvw8
 uDgUAKv8HQFviEGeUpQSoZLKoqxk3udT+9UEDHdUFZzUw6cb7nBL5RR05s0gSmFtZXMgSC4g
 R2Fycmlzb24gPGpoZ0BqaG1nLm5ldD7CZgQTEQIAJgIbIwIeAQIXgBYhBE0k6YNkgIecKmav
 NClu/GJwc42IBQJa/b1KAAoJEClu/GJwc42I7XIAniCLaMTp2qpwYcWGKiRES8CL4xmOAKDk
 pqXJ1LA3JyWt30h9ARgRRiNOCM7BTQQ1hFqHEAgA9kJXtwh/CBdyorrWqULzBej5UxE5T7bx
 brlLOCDaAadWoxTpj0BV89AHxstDqZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z
 4VeSWc39uK50T8X8dryDxUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1Y
 TknbzSC0neSRBzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdXQ6Md
 GGzeMyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbTCD1mpF1Bn5x8
 vYlLIhkmuquiXsNV6TILOwACAgf/T9Es2C7dcY05hRsH/rhGC+spnzHnhlUDJed75t/JMQM2
 KQDxLpP+qSUB80JHgGCOea4YKqJmWnBrU1uKdCc19qy87p5bc6QxoqpKrt2SxayqSpGnWQlj
 eqlVIRPC2jm2QbqaWTZtQpyDwfkTbnGBnkp+tJomtPBATviM5S5jiQZKKTDBN70807J75hAn
 IRKD6L+QPbVzFt0yaS0LUsolzBrPE2pR228uNFjj7z5Mgq1la2AhKFM/MIM9i+Wc5j3MEEFU
 386cRSG+RyDQLKch6j+SgbX62BdOQxAF4EWRKIfU9xw7czC8AIMRTdAc1VyMIGE7asD7EwU6
 iRzcEGdAU8JGBBgRAgAGBQI1hFqHAAoJEClu/GJwc42ItM4AoL+kbkqNvMdUwSGxECYAMAFe
 gz3TAJ4wt2K8xQhx5iPuLTZFPyZoC8vrdw==
X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_PASS, SPF_PASS, TXREP,
 T_SCC_BODY_TEXT_LINE,
 WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Jim Garrison via Cygwin <cygwin@cygwin.com>
Reply-To: jhg@acm.org
Cc: Jim Garrison <jhg@jhmg.net>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

Win 11 Cygwin "dig" and "host": Option -6 causes command to hang

TL;DR
-----

It appears "dig" and "host" both depend on the existence of 
/etc/resolv.conf, but only when the -6 option (send queries over IPv6) 
is specified.

/etc/resolv.conf does not exist on either my old Win 10 or relatively 
new Win 11 systems.

I have a vague recollection that at some point, maybe Windows 7 or even 
XP, there was a Cygwin /etc/resolv.conf that was a link to 
C:\windows\system32\drivers\etc\resolv.conf, but I don't think this has 
been true for quite a while if it ever was.  Also resolv.conf does not 
exist in the windows location either.

Details
-------

Sample:

     # Default query over IPv4
     $ host google.com
     google.com has address 74.125.197.102
     google.com has address 74.125.197.100
     google.com has address 74.125.197.138
     google.com has address 74.125.197.101
     google.com has address 74.125.197.139
     google.com has address 74.125.197.113
     google.com has IPv6 address 2607:f8b0:400e:c03::64
     google.com has IPv6 address 2607:f8b0:400e:c03::71
     google.com has IPv6 address 2607:f8b0:400e:c03::65
     google.com has IPv6 address 2607:f8b0:400e:c03::66
     google.com mail is handled by 10 smtp.google.com.


     # Query over IPv6
     $ host -6 google.com
     ;; connection timed out; no servers could be reached

     # Query over IPv6 with explicit DNS server
     $ host -6 google.com 2601:xxx:xxx:xxx:201:2eff:fe70:3bfe
     Using domain server:
     Name: 2601:xxx:xxx:xxx:201:2eff:fe70:3bfe
     Address: 2601:xxx:xxx:xxx:201:2eff:fe70:3bfe#53
     Aliases:

     google.com has address 74.125.197.139
     google.com has address 74.125.197.113
     google.com has address 74.125.197.102
     google.com has address 74.125.197.100
     google.com has address 74.125.197.138
     google.com has address 74.125.197.101
     google.com has IPv6 address 2607:f8b0:400e:c03::71
     google.com has IPv6 address 2607:f8b0:400e:c03::65
     google.com has IPv6 address 2607:f8b0:400e:c03::66
     google.com has IPv6 address 2607:f8b0:400e:c03::64
     google.com mail is handled by 10 smtp.google.com.

I ran the failing command above in strace and saw that it's trying to 
open /etc/resolv.conf

     [...]
       206  515079 [main] host 2426 open: open(/etc/resolv.conf, 0x0)
        58  515137 [main] host 2426 normalize_posix_path: src 
/etc/resolv.conf
        59  515196 [main] host 2426 normalize_posix_path: 
/etc/resolv.conf = normalize_posix_path (/etc/resolv.conf)
        63  515259 [main] host 2426 mount_info::conv_to_win32_path: 
conv_to_win32_path (/etc/resolv.conf)
        68  515327 [main] host 2426 mount_info::cygdrive_win32_path: src 
'/etc/resolv.conf', dst ''
        61  515388 [main] host 2426 mount_info::conv_to_win32_path: 
src_path /etc/resolv.conf, dst C:\cygwin64\etc\resolv.conf, flags 
0x30008, rc 0
        81  515469 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf)
        82  515551 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf)
        90  515641 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf.exe)
        81  515722 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf.exe)
        90  515812 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf.lnk)
        81  515893 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf.lnk)
        88  515981 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf.exe.lnk)
        82  516063 [main] host 2426 symlink_info::check: 0xC0000034 = 
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf.exe.lnk)
        81  516144 [main] host 2426 symlink_info::check: 0 = 
symlink.check(C:\cygwin64\etc\resolv.conf, 0x7FFFFB4B0) (mount_flags 
0x30008, path_flags 0x0)
        64  516208 [main] host 2426 mount_info::conv_to_win32_path: 
conv_to_win32_path (/etc)
        59  516267 [main] host 2426 mount_info::cygdrive_win32_path: src 
'/etc', dst ''
        60  516327 [main] host 2426 mount_info::conv_to_win32_path: 
src_path /etc, dst C:\cygwin64\etc, flags 0x30008, rc 0
        69  516396 [main] host 2426 symlink_info::check: 0x0 = 
NtCreateFile (\??\C:\cygwin64\etc)
       233  516629 [main] host 2426 symlink_info::check: not a symlink
        65  516694 [main] host 2426 symlink_info::check: 0 = 
symlink.check(C:\cygwin64\etc, 0x7FFFFB4B0) (mount_flags 0x30008, 
path_flags 0x0)
        62  516756 [main] host 2426 path_conv::check: 
this->path(C:\cygwin64\etc\resolv.conf), has_acls(1)
        61  516817 [main] host 2426 build_fh_pc: fh 0x80000BE18, dev 
000000C3
        60  516877 [main] host 2426 fhandler_base::open: 
(\??\C:\cygwin64\etc\resolv.conf, 0x0)
        89  516966 [main] host 2426 seterrno_from_nt_status: 
/cygdrive/d/a/scallywag/cygwin/cygwin-3.5.0-1.x86_64/src/newlib-cygwin/winsup/cygwin/fhandler/base.cc:717 
status 0xC0000034 -> windows error 2
        75  517041 [main] host 2426 geterrno_from_win_error: windows 
error 2 == errno 2
        59  517100 [main] host 2426 fhandler_base::open: 0xC0000034 = 
NtCreateFile (0x7FF84CA3A060, 0x80100000, 
\??\C:\cygwin64\etc\resolv.conf, io, NULL, 0x0, 0x7, 0x1, 0x4020, NULL, 0)
        85  517185 [main] host 2426 fhandler_base::open: 0 = 
fhandler_base::open(\??\C:\cygwin64\etc\resolv.conf, 0x0)
        90  517275 [main] host 2426 fhandler_base::open_fs: 0 = 
fhandler_disk_file::open(\??\C:\cygwin64\etc\resolv.conf, 0x0)
        90  517365 [main] host 2426 open: -1 = open(/etc/resolv.conf, 
0x0), errno 2
     [...]

I confirmed this was the problem by creating /etc/resolv.conf (within 
the Cygwin root, not a symlink) and included the search domain and IPv4 
and IPv6 dns servers, after which the -6 option no longer timed out.

-- 
Jim Garrison
jhg@acm.org

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