From f19de48d944aa98686f813a50a2f372f317d16b2 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Mon, 15 Apr 2024 12:14:50 +0100 Subject: [PATCH] os_release.go: Follow symlink to real os-release path. Fixes: #2981 Signed-off-by: Jonathan Davies --- collector/os_release.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/collector/os_release.go b/collector/os_release.go index 5d2e94296c..65c5c4cccc 100644 --- a/collector/os_release.go +++ b/collector/os_release.go @@ -18,6 +18,7 @@ import ( "errors" "io" "os" + "path/filepath" "regexp" "strconv" "strings" @@ -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