aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar John Belamaric <jbelamaric@infoblox.com> 2017-09-29 17:28:37 -0400
committerGravatar Miek Gieben <miek@miek.nl> 2017-09-29 22:28:37 +0100
commit37d06f382a71f449e9f10eff219d2e2e2036cc98 (patch)
treebffc1d7ad70f1c6808e9e68f8d2dc7efd0bdf3a2
parent4276d29b81575992bf0c7525b4cb5716d493e913 (diff)
downloadcoredns-37d06f382a71f449e9f10eff219d2e2e2036cc98.tar.gz
coredns-37d06f382a71f449e9f10eff219d2e2e2036cc98.tar.zst
coredns-37d06f382a71f449e9f10eff219d2e2e2036cc98.zip
Warn if the hosts file is a directory (#1126)
-rw-r--r--plugin/hosts/setup.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugin/hosts/setup.go b/plugin/hosts/setup.go
index 0c13140bb..48beb0dcb 100644
--- a/plugin/hosts/setup.go
+++ b/plugin/hosts/setup.go
@@ -50,7 +50,7 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
if !path.IsAbs(h.path) && config.Root != "" {
h.path = path.Join(config.Root, h.path)
}
- _, err := os.Stat(h.path)
+ s, err := os.Stat(h.path)
if err != nil {
if os.IsNotExist(err) {
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)
}
}
+ if s != nil && s.IsDir() {
+ log.Printf("[WARNING] hosts file %q is a directory", h.path)
+ }
}
origins := make([]string, len(c.ServerBlockKeys))