net: myhostname nss module doesn't work if hostname contains dots #17967
Comments
Here is an example of this behavior on ec2:
|
This is getting late for 1.8 but if the patch is really simple it could go in. |
CL incoming for this. I went ahead and added support for other special names per the man page but happy to back that out. |
CL https://golang.org/cl/33550 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
222 if src.source == "myhostname" {
223 if hostname == "" || hasDot {
224 continue
225 }
226 return fallbackOrder
227 }
The intent of this block appears to be that for a non-dotted name (which presumably is the local hostname) the fallback should be performed to allow nss-myhostname to attempt resolution of the name as a local hostname.
Unfortunately many installations, including cloud-based hosts, use fully qualified domain names as their hostname. hostname(1) on Linux even says:
It doesn't look like anywhere else in the Go resolver has special logic for handling the local hostname, so if your system hostname is an FQDN, go appears to bypass nss-myhostname. If your upstream DNS server cannot resolve the local hostname FQDN, and the hostname is not listed in /etc/hosts, then resolution will fail. But that's precisely what nss-myhostname was created to avoid, yet Go will ignore it.
Not sure what the best option here is, except that if myhostname is in nsswitch.conf, then either the Go resolver should attempt to do the mapping between local hostname and hostname internally, or it should pass the lookup off to netdns=cgo after trying its internal dns+files and getting failure from both of those?
The text was updated successfully, but these errors were encountered: