Skip to content

Commit

Permalink
Add 1st level symlink follow on walkdirs
Browse files Browse the repository at this point in the history
Signed-off-by: Xabier Larrakoetxea <me@slok.dev>
  • Loading branch information
slok committed Dec 30, 2024
1 parent 4307691 commit f631626
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- Follow 1st level symlinks when discovery paths like private keys directories (adding symlink follow at all levels adds too many edge cases).

## [v0.7.2] - 2024-12-19

### Changed
Expand Down
8 changes: 8 additions & 0 deletions internal/storage/fs/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ func (fileManager) StatFile(_ context.Context, path string) (os.FileInfo, error)
return os.Stat(path)
}
func (fileManager) WalkDir(_ context.Context, root string, fn fs.WalkDirFunc) error {
// Symlinks walkdirs have lots of edge cases so as a middle ground between reliability, simplicity and practicality
// we will only support first level symlinks (as ~/.ssh being a symlink can be a common use case).
// More info here: https://github.com/golang/go/issues/49580
evalRoot, err := filepath.EvalSymlinks(root)
if err == nil {
root = evalRoot
}

return filepath.WalkDir(root, fn)
}

Expand Down

0 comments on commit f631626

Please sign in to comment.