Commit f24ba9d3 authored by linxin's avatar linxin Committed by Brad Davidson

Validate resolv.conf for presence of nameserver entries

parent 2669d67a
......@@ -316,19 +316,22 @@ func isValidResolvConf(resolvConfFile string) bool {
nameserver := regexp.MustCompile(`^nameserver\s+([^\s]*)`)
scanner := bufio.NewScanner(file)
foundNameserver := false
for scanner.Scan() {
ipMatch := nameserver.FindStringSubmatch(scanner.Text())
if len(ipMatch) == 2 {
ip := net.ParseIP(ipMatch[1])
if ip == nil || !ip.IsGlobalUnicast() {
return false
} else {
foundNameserver = true
}
}
}
if err := scanner.Err(); err != nil {
return false
}
return true
return foundNameserver
}
func locateOrGenerateResolvConf(envInfo *cmds.Agent) string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment