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: a nsswitch.conf hosts: entry with 'myhostname' forces cgo lookups for LookupPort() and others #13623

Closed
siebenmann opened this issue Dec 15, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@siebenmann
Copy link

commented Dec 15, 2015

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.)

@bradfitz

This comment has been minimized.

Copy link
Member

commented Dec 15, 2015

Do you call LookupPort enough to matter either way?

@siebenmann

This comment has been minimized.

Copy link
Author

commented Dec 15, 2015

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.

@rsc rsc added this to the Go1.6Maybe milestone Dec 28, 2015

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jan 6, 2016

I think this case is rare enough to wait for Go 1.7 at this point. I sent CL 18329.

@rsc rsc modified the milestones: Go1.7Early, Go1.6Maybe Jan 6, 2016

@gopherbot

This comment has been minimized.

Copy link

commented Feb 18, 2016

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

@gopherbot gopherbot closed this in fafd792 May 5, 2016

@gopherbot

This comment has been minimized.

Copy link

commented May 5, 2016

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

@golang golang locked and limited conversation to collaborators May 5, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.