mirror of
https://github.com/coredns/coredns.git
synced 2026-04-09 21:45:32 -04:00
fix(auto): resolve symlinked directory before walk (#8032)
This commit is contained in:
@@ -14,12 +14,20 @@ import (
|
||||
func (a Auto) Walk() error {
|
||||
// TODO(miek): should add something so that we don't stomp on each other.
|
||||
|
||||
// Resolve symlinks in the directory path so filepath.Walk will traverse it.
|
||||
// filepath.Walk uses os.Lstat on the root and won't enter a symlinked directory.
|
||||
// This is needed when DIR itself is a symlink (e.g., Kubernetes ConfigMap mounts).
|
||||
dir := a.directory
|
||||
if resolved, err := filepath.EvalSymlinks(a.directory); err == nil {
|
||||
dir = resolved
|
||||
}
|
||||
|
||||
toDelete := make(map[string]bool)
|
||||
for _, n := range a.Names() {
|
||||
toDelete[n] = true
|
||||
}
|
||||
|
||||
filepath.Walk(a.directory, func(path string, info os.FileInfo, e error) error {
|
||||
filepath.Walk(dir, func(path string, info os.FileInfo, e error) error {
|
||||
if e != nil {
|
||||
log.Warningf("error reading %v: %v", path, e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user