Skip to content

net: Building with netgo doesn't respect nsswitch.conf #14354

@vishvananda

Description

@vishvananda

Commit 4a0ba7a allowed golang 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. It seems like it would be better to parse the file and only fallback to hostLookupFilesDNS if it would normally use hostLookupCgo.

I noticed this because I have a static binary built with cgo, and it is using files for lookup even when nsswitch.conf specifies:

hosts:      dns

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions