Skip to content

Commit

Permalink
Merge pull request #3799 from fastest963/fileNotDir
Browse files Browse the repository at this point in the history
Resolve symlinks in config directory
  • Loading branch information
kyhavlov authored Jan 18, 2018
2 parents 410e961 + aedab91 commit a9139ca
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion agent/config/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,25 @@ func (b *Builder) ReadPath(path string) ([]Source, error) {

var sources []Source
for _, fi := range fis {
fp := filepath.Join(path, fi.Name())
// check for a symlink and resolve the path
if fi.Mode()&os.ModeSymlink > 0 {
var err error
fp, err = filepath.EvalSymlinks(fp)
if err != nil {
return nil, err
}
fi, err = os.Stat(fp)
if err != nil {
return nil, err
}
}
// do not recurse into sub dirs
if fi.IsDir() {
continue
}

src, err := b.ReadFile(filepath.Join(path, fi.Name()))
src, err := b.ReadFile(fp)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a9139ca

Please sign in to comment.