mirror of
https://github.com/coredns/coredns.git
synced 2025-11-06 20:16:28 -05:00
Warn if the hosts file is a directory (#1126)
This commit is contained in:
committed by
Miek Gieben
parent
4276d29b81
commit
37d06f382a
@@ -50,7 +50,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
|||||||
if !path.IsAbs(h.path) && config.Root != "" {
|
if !path.IsAbs(h.path) && config.Root != "" {
|
||||||
h.path = path.Join(config.Root, h.path)
|
h.path = path.Join(config.Root, h.path)
|
||||||
}
|
}
|
||||||
_, err := os.Stat(h.path)
|
s, err := os.Stat(h.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
log.Printf("[WARNING] File does not exist: %s", h.path)
|
log.Printf("[WARNING] File does not exist: %s", h.path)
|
||||||
@@ -58,6 +58,9 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
|||||||
return h, c.Errf("unable to access hosts file '%s': %v", h.path, err)
|
return h, c.Errf("unable to access hosts file '%s': %v", h.path, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if s != nil && s.IsDir() {
|
||||||
|
log.Printf("[WARNING] hosts file %q is a directory", h.path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
origins := make([]string, len(c.ServerBlockKeys))
|
origins := make([]string, len(c.ServerBlockKeys))
|
||||||
|
|||||||
Reference in New Issue
Block a user