Skip to content

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

@siebenmann

Description

@siebenmann

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeTestingAn issue that has been verified to require only test changes, not just a test failure.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions