net: a nsswitch.conf hosts: entry with 'myhostname' forces cgo lookups for LookupPort() and others #13623
Labels
Milestone
Comments
Do you call LookupPort enough to matter either way? |
I don't, and I suspect that few or no people do. People may call LookupAddr() more frequently, though; I do have a daemon that calls LookupAddr() on every connection. Although people who care that much can always force the pure Go resolver to be used. |
I think this case is rare enough to wait for Go 1.7 at this point. I sent CL 18329. |
CL https://golang.org/cl/18329 mentions this issue. |
CL https://golang.org/cl/22821 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
net.LookupPort(), net.LookupCNAME(), and net.LookupAddr() all wind up trying to decide whether to use cgo lookups or the pure Go lookups by calling hostLookupOrder("") (via canUseCgo()). Because the empty string contains no dots, it matches the 'nsswitch.conf hosts line contains myhostname and hostname to be looked up contains no dots' check that forces the use of cgo. I suspect that this is unintentional, as at least the port lookup isn't a hostname related one and so won't actually use the myhostname NSS module.
(It may be necessary for LookupCNAME() to care about myhostname here, unlike at least port lookup.)
The text was updated successfully, but these errors were encountered: