Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: dnsclient_unix_test.go will fail on a machine with 'test' in /etc/hosts and 'files' first in nsswitch.conf #19592

Closed
siebenmann opened this issue Mar 17, 2017 · 5 comments
Labels
FrozenDueToAge Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@siebenmann
Copy link

What version of Go are you using (go version)?

This issue reproduces when building the current git tip version of go, b9f6b22. Because it blocks finishing the build, I cannot show you literal 'go version' output on the affected machine. Testing says that this was introduced in commit bfc164c, 'net: add Resolver.StrictErrors', intended to fix issue #17448.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

This also reproduces on FreeBSD.

What did you do?

Configure a machine with an /etc/hosts entry for the name test, such as:

199.199.199.199   test

Then set /etc/nsswitch.conf to have hosts: files dns, so that /etc/hosts is checked before DNS. Then attempt to build go from source.

What did you expect to see?

Build succeeds.

What did you see instead?

The build fails in dnsclient_unix_test.go where a whole bunch of DNS tests expect to get various errors or results when looking up the name 'test' but instead get the test entry from /etc/hosts.

--- FAIL: TestStrictErrorsLookupIP (0.00s)
        dnsclient_unix_test.go:1112: #0 (No errors) strict=true: got ips map[199.199.199.199:{}]; want map[2001:db8::1:{} 192.0.2.1:{}]
        dnsclient_unix_test.go:1112: #0 (No errors) strict=false: got ips map[199.199.199.199:{}]; want map[192.0.2.1:{} 2001:db8::1:{}]
        dnsclient_unix_test.go:1098: #1 (searchX error fails in strict mode) strict=true: got err <nil>; want &net.DNSError{Err:"i/o timeout", Name:"test", Server:"192.0.2.53:53", IsTimeout:true, IsTemporary:false}
        dnsclient_unix_test.go:1112: #1 (searchX error fails in strict mode) strict=true: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1112: #1 (searchX error fails in strict mode) strict=false: got ips map[199.199.199.199:{}]; want map[192.0.2.1:{} 2001:db8::1:{}]
        dnsclient_unix_test.go:1098: #2 (searchX IPv4-only timeout fails in strict mode) strict=true: got err <nil>; want &net.DNSError{Err:"i/o timeout", Name:"test", Server:"192.0.2.53:53", IsTimeout:true, IsTemporary:false}
        dnsclient_unix_test.go:1112: #2 (searchX IPv4-only timeout fails in strict mode) strict=true: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1112: #2 (searchX IPv4-only timeout fails in strict mode) strict=false: got ips map[199.199.199.199:{}]; want map[192.0.2.1:{} 2001:db8::1:{}]
        dnsclient_unix_test.go:1098: #3 (searchX IPv6-only servfail fails in strict mode) strict=true: got err <nil>; want &net.DNSError{Err:"server misbehaving", Name:"test", Server:"192.0.2.53:53", IsTimeout:false, IsTemporary:true}
        dnsclient_unix_test.go:1112: #3 (searchX IPv6-only servfail fails in strict mode) strict=true: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1112: #3 (searchX IPv6-only servfail fails in strict mode) strict=false: got ips map[199.199.199.199:{}]; want map[192.0.2.1:{} 2001:db8::1:{}]
        dnsclient_unix_test.go:1098: #4 (searchY error always fails) strict=true: got err <nil>; want &net.DNSError{Err:"i/o timeout", Name:"test", Server:"192.0.2.53:53", IsTimeout:true, IsTemporary:false}
        dnsclient_unix_test.go:1112: #4 (searchY error always fails) strict=true: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1098: #4 (searchY error always fails) strict=false: got err <nil>; want &net.DNSError{Err:"no such host", Name:"test", Server:"192.0.2.53:53", IsTimeout:false, IsTemporary:false}
        dnsclient_unix_test.go:1112: #4 (searchY error always fails) strict=false: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1098: #5 (searchY IPv4-only socket error fails in strict mode) strict=true: got err <nil>; want &net.DNSError{Err:"write: socket on fire", Name:"test", Server:"192.0.2.53:53", IsTimeout:false, IsTemporary:true}
        dnsclient_unix_test.go:1112: #5 (searchY IPv4-only socket error fails in strict mode) strict=true: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1112: #5 (searchY IPv4-only socket error fails in strict mode) strict=false: got ips map[199.199.199.199:{}]; want map[2001:db8::1:{}]
        dnsclient_unix_test.go:1098: #6 (searchY IPv6-only timeout fails in strict mode) strict=true: got err <nil>; want &net.DNSError{Err:"i/o timeout", Name:"test", Server:"192.0.2.53:53", IsTimeout:true, IsTemporary:false}
        dnsclient_unix_test.go:1112: #6 (searchY IPv6-only timeout fails in strict mode) strict=true: got ips map[199.199.199.199:{}]; want map[]
        dnsclient_unix_test.go:1112: #6 (searchY IPv6-only timeout fails in strict mode) strict=false: got ips map[199.199.199.199:{}]; want map[192.0.2.1:{}]
FAIL
FAIL    net     1.533s
@mdempsky mdempsky self-assigned this Mar 17, 2017
@mdempsky
Copy link
Member

mdempsky commented Mar 17, 2017

Out of curiosity, why do you have a test entry in your /etc/hosts? Is that just a personal config you have? Is there some software you're using that uses that? Were you just wanting to demonstrate an issue with the package net tests?

@bradfitz bradfitz added the Testing An issue that has been verified to require only test changes, not just a test failure. label Mar 17, 2017
@bradfitz bradfitz added this to the Go1.9 milestone Mar 17, 2017
@siebenmann
Copy link
Author

I originally encountered this issue on a (FreeBSD) machine run by another group here at the university. Their habit is to have a full /etc/hosts where entries for hosts in their subdomain(s) have an entry for host's bare hostname (eg IP machine.subdomain machine). And they have a machine called test.<subdomain>, so they wind up with an /etc/hosts entry of IP test.subdomain test.

I tested this on my Linux machine with an artificial /etc/hosts entry to make sure I understood the issue and could confidently reproduce it in an environment where I could make changes to the system to test any questions or proposed fixes (I don't have root access to that other group's machines).

@mdempsky
Copy link
Member

@siebenmann Can you confirm whether the fix in https://go-review.googlesource.com/c/38300/ works for you?

@gopherbot
Copy link

CL https://golang.org/cl/38300 mentions this issue.

@siebenmann
Copy link
Author

@mdempsky I hand-applied the change to my source and this appears to completely fix the issue; I get no build failure here on the FreeBSD server with the original problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

4 participants