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: support "ndots:" of 0 in resolv.conf? #15419

Closed
ywk253100 opened this issue Apr 23, 2016 · 3 comments
Closed

net: support "ndots:" of 0 in resolv.conf? #15419

ywk253100 opened this issue Apr 23, 2016 · 3 comments

Comments

@ywk253100
Copy link

I saw the source code of net/dnsconfig_unix.go line 84:

case "options": // magic options
            for _, s := range f[1:] {
                switch {
                case hasPrefix(s, "ndots:"):
                    n, _, _ := dtoi(s, 6)
                    if n < 1 {
                        n = 1
                    }
                    conf.ndots = n

And found that if the value of "ndots:" less than 1, it will be set to 1. But does this make sense? Why can't it be set to 0?

The way how pure Go DNS resolver resolves names caused an error in my program. When I set "ndots:" to 0 and resolved "mysql", I wanted to resolve "mysql." first, but instead, pure Go DNS resolver resolved "mysql.searchdomain." first. As it happened, the domain name"mysql.searchdomain." was valid in my DNS server, so I got a wrong IP of mysql.

When I set "GODEBUG=netdns=cgo" and used the cgo-based resolver, the program worked well.

@bradfitz bradfitz changed the title It does not work when set "ndots:" to 0 in resolv.conf net: support "ndots:" of 0 in resolv.conf? Apr 23, 2016
@bradfitz bradfitz added this to the Unplanned milestone Apr 23, 2016
@bradfitz
Copy link
Contributor

/cc @mdempsky

@mdempsky
Copy link
Member

Allowing ndots to go down to 0 seems okay to me. Package net should handle that correctly, and BIND libresolv allows it.

OpenBSD libc only allows ndots to go down to 1. I don't see any reason for that though, so I'm wondering if it's an off-by-1. (Instead of allowing 0--15 like BIND, OpenBSD allows 1--16.)

bombela added a commit to yarpc/yarpc-go that referenced this issue Jun 20, 2016
 - the native go DNS resolver doesn't handle `ndots:0` anyway
   (golang/go#15419)
 - we might as well set our containers DNS configuration to absolute
   hostnames for consistency.
bombela added a commit to crossdock/crossdock that referenced this issue Jun 20, 2016
 - the native go DNS resolver doesn't handle `ndots:0` anyway
   (golang/go#15419)
 - we might as well set our containers DNS configuration to absolute
   hostnames for consistency.
bombela added a commit to yarpc/yarpc-go that referenced this issue Jun 20, 2016
- the native go DNS resolver doesn't handle `ndots:0` anyway
   (golang/go#15419)
 - we might as well set our containers DNS configuration to absolute
   hostnames for consistency.
bombela added a commit to crossdock/crossdock that referenced this issue Jun 20, 2016
- the native go DNS resolver doesn't handle `ndots:0` anyway
   (golang/go#15419)
 - we might as well set our containers DNS configuration to absolute
   hostnames for consistency.
@gopherbot
Copy link

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

gopherbot pushed a commit that referenced this issue Aug 17, 2016
Updates #15419.

Change-Id: If7c80adcb38b5731e337b2ae2d9d76fcf8513d8e
Reviewed-on: https://go-review.googlesource.com/27271
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Aug 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants