Skip to content

Commit

Permalink
os_release.go: Follow symlink to real os-release path.
Browse files Browse the repository at this point in the history
Fixes: #2981

Signed-off-by: Jonathan Davies <jpds@protonmail.com>
  • Loading branch information
jpds committed Apr 15, 2024
1 parent bf67c85 commit f19de48
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions collector/os_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"errors"
"io"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -128,6 +129,11 @@ func parseOSRelease(r io.Reader) (*osRelease, error) {
}

func (c *osReleaseCollector) UpdateStruct(path string) error {
path, err := filepath.EvalSymlinks(path)
if err != nil {
return err
}

releaseFile, err := os.Open(path)
if err != nil {
return err
Expand Down

0 comments on commit f19de48

Please sign in to comment.