-
Notifications
You must be signed in to change notification settings - Fork 18k
net: force cgo for myhostname and mdns nss modules for LookupAddr on unix #59921
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
Conversation
This PR (HEAD: 3d81b56) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/491235 to see it. Tip: You can toggle comments from me using the |
Message from Mateusz Poliwczak: Patch Set 1: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
Message from Gopher Robot: Patch Set 1: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
Message from Ian Lance Taylor: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
This PR (HEAD: d83d39b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/491235 to see it. Tip: You can toggle comments from me using the |
Message from Mateusz Poliwczak: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
This PR (HEAD: ade40fd) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/491235 to see it. Tip: You can toggle comments from me using the |
Message from Mateusz Poliwczak: Patch Set 3: Run-TryBot+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
Message from Gopher Robot: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
Message from Gopher Robot: Patch Set 3: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
Message from Ian Lance Taylor: Patch Set 3: Auto-Submit+1 Code-Review+2 Run-TryBot+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
…unix Currently there is a small bug in the LookupAddr for unix systems that causes the use of go resolver instead of the cgo one. Example for nss myhostname: func main() { fmt.Println(net.LookupAddr(os.Args[1])) } root@arch:~# cat /etc/nsswitch.conf | grep host hosts: myhostname dns root@arch:~# GODEBUG=netdns=+3 go run main.go 192.168.1.200 go package net: confVal.netCgo = false netGo = false go package net: dynamic selection of DNS resolver go package net: hostLookupOrder() = dns [] lookup 200.1.168.192.in-addr.arpa. on 8.8.8.8:53: no such host root@arch:~# GODEBUG=netdns=go+3 go run main.go 192.168.1.200 go package net: confVal.netCgo = false netGo = true go package net: GODEBUG setting forcing use of Go's resolver go package net: hostLookupOrder() = dns [] lookup 200.1.168.192.in-addr.arpa. on 8.8.8.8:53: no such host root@arch:~# GODEBUG=netdns=cgo+3 go run main.go 192.168.1.200 go package net: confVal.netCgo = true netGo = false go package net: using cgo DNS resolver go package net: hostLookupOrder() = cgo [arch] <nil> The problem come from that we are only checking for hostnames that the myhostname can resolve, but not for the addrs that it can also. man nss-myhostname: Please keep in mind that nss-myhostname (and nss-resolve) also resolve in the other direction — from locally attached IP addresses to hostnames. Change-Id: Ic18a9f99a2214b2938463e9a95f7f3ca5db1c01b GitHub-Last-Rev: ade40fd GitHub-Pull-Request: #59921 Reviewed-on: https://go-review.googlesource.com/c/go/+/491235 Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Mateusz Poliwczak <[email protected]>
Message from Cherry Mui: Patch Set 3: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/491235. |
This PR is being closed because golang.org/cl/491235 has been merged. |
Currently there is a small bug in the LookupAddr for unix systems
that causes the use of go resolver instead of the cgo one.
Example for nss myhostname:
func main() {
fmt.Println(net.LookupAddr(os.Args[1]))
}
root@arch:
# cat /etc/nsswitch.conf | grep host# GODEBUG=netdns=+3 go run main.go 192.168.1.200hosts: myhostname dns
root@arch:
go package net: confVal.netCgo = false netGo = false
go package net: dynamic selection of DNS resolver
go package net: hostLookupOrder() = dns
[] lookup 200.1.168.192.in-addr.arpa. on 8.8.8.8:53: no such host
root@arch:
# GODEBUG=netdns=go+3 go run main.go 192.168.1.200# GODEBUG=netdns=cgo+3 go run main.go 192.168.1.200go package net: confVal.netCgo = false netGo = true
go package net: GODEBUG setting forcing use of Go's resolver
go package net: hostLookupOrder() = dns
[] lookup 200.1.168.192.in-addr.arpa. on 8.8.8.8:53: no such host
root@arch:
go package net: confVal.netCgo = true netGo = false
go package net: using cgo DNS resolver
go package net: hostLookupOrder() = cgo
[arch]
The problem come from that we are only checking for hostnames that the
myhostname can resolve, but not for the addrs that it can also.
man nss-myhostname:
Please keep in mind that nss-myhostname (and nss-resolve) also
resolve in the other direction — from locally attached IP
addresses to hostnames.