net: allow netgo to use lookup from nsswitch.conf
Change https://golang.org/cl/8945 allowed Go to use its own DNS resolver instead of libc in a number of cases. The code parses nsswitch.conf and attempts to resolve things in the same order. Unfortunately, builds with netgo completely ignore this parsing and always search via hostLookupFilesDNS. This commit modifies the logic to allow binaries built with netgo to parse nsswitch.conf and attempt to resolve using the order specified there. If the parsing results in hostLookupCGo, it falls back to the original hostLookupFilesDNS. Tests are also added to ensure that both the parsing and the fallback work properly. Fixes #14354 Change-Id: Ib079ad03d7036a4ec57f18352a15ba55d933f261 Reviewed-on: https://go-review.googlesource.com/19523 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Showing
Please
register
or
sign in
to comment