Skip to content

fix(auto): resolve symlinked directory before walk#8032

Merged
yongtang merged 1 commit into
coredns:masterfrom
thevilledev:fix/auto-symlinked-directory
Apr 8, 2026
Merged

fix(auto): resolve symlinked directory before walk#8032
yongtang merged 1 commit into
coredns:masterfrom
thevilledev:fix/auto-symlinked-directory

Conversation

@thevilledev

@thevilledev thevilledev commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

1. Why is this pull request needed and what does it do?

When the auto plugin directory directive points to a symlink (e.g. a Kubernetes ConfigMap mount), the walk never enters the directory and no zone files are discovered. Reason is that filepath.Walk uses os.Lstat on the root path, which does not follow symlinks.

Resolve the directory path with filepath.EvalSymlinks before each walk so that filepath.Walk sees a real directory. On failure the original path is used, preserving existing behavior.

The tests fail against master:

--- FAIL: TestWalkSymlinkedDirectory (0.00s)
    walk_test.go:78: example.com. should have been added when directory is a symlink
    walk_test.go:78: example.org. should have been added when directory is a symlink

2. Which issues (if any) are related?

Fixes #8016

3. Which documentation changes (if any) need to be made?

None.

4. Does this introduce a backward incompatible change or deprecation?

No.

When the `auto` plugin `directory` directive points to a symlink
(e.g. a Kubernetes ConfigMap mount), the walk never enters the
directory and no zone files are discovered. Reason is that
`filepath.Walk` uses `os.Lstat` on the root path, which does
not follow symlinks.

Resolve the directory path with `filepath.EvalSymlinks` before
each walk so that `filepath.Walk` sees a real directory. On
failure the original path is used, preserving existing behavior.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
@thevilledev thevilledev marked this pull request as ready for review April 8, 2026 18:41
@thevilledev thevilledev requested review from miekg and stp-ip as code owners April 8, 2026 18:41
@yongtang yongtang merged commit 4c71636 into coredns:master Apr 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto plugin does not work if DIR is a symlink

2 participants