Remove nameserver 127.0.0.1 line rather then dumping resolv.conf

We have a bug report complaining about docker dumping the contents of the
hosts resolv.conf if it container 127.0.0.1.  They asked that instead
of dropping the file altogether, that we just remove the line.

This patch removes the 127.0.0.1 lines, if they exist and then
checks if any nameserver lines exist.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Hi Dan, please try: http://play.golang.org/p/qxRecxvlVU

Which should match a newline if it exists, and will only cover the same line. It will also replace all the 127.x.x.x entries.

On Sep 23, 2014, at 2:17 PM, rhatdan <notifications@github.com> wrote:

> In utils/utils.go:
> 
> > @@ -332,6 +333,17 @@ func CheckLocalDns(resolvConf []byte) bool {
> >  	return true
> >  }
> >  
> > +var (
> > +	localhostRx = regexp.MustCompile("nameserver\\s+127.*\\n?")
> If you have a 127.0.0.1 line with no \n
> 
> —
> Reply to this email directly or view it on GitHub.
>