From cdb3f5c8574a8dc82d8aa27219b0d804bdafa0b2 Mon Sep 17 00:00:00 2001 From: Al Cutter Date: Wed, 27 Mar 2024 14:08:06 +0000 Subject: [PATCH] Fix OS handling of version string --- trusted_os/ctl.go | 10 +--------- trusted_os/main.go | 4 +++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/trusted_os/ctl.go b/trusted_os/ctl.go index 529ebfd..05ac5a0 100644 --- a/trusted_os/ctl.go +++ b/trusted_os/ctl.go @@ -64,19 +64,11 @@ type controlInterface struct { } func getStatus() (s *api.Status) { - version, err := parseVersion(Version) - versionString := "unknown" - if err != nil { - log.Printf("failed to get version: %v", err) - } else { - versionString = version.String() - } - s = &api.Status{ SRKHash: SRKHash, Revision: Revision, Build: Build, - Version: versionString, + Version: osVersion.String(), Runtime: fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH), // TODO(jayhou): set IdentityCounter here. } diff --git a/trusted_os/main.go b/trusted_os/main.go index 6bc5a3b..6f76382 100644 --- a/trusted_os/main.go +++ b/trusted_os/main.go @@ -135,6 +135,8 @@ func main() { if imx6ul.Native && imx6ul.OCOTP != nil { imx6ul.OCOTP.Timeout = 100 * time.Millisecond } + // Strip off v from GitTag so we can semver parse it. + Version = strings.TrimPrefix(Version, "v") var err error @@ -195,7 +197,7 @@ func main() { log.Fatalf("SM failed to create OS bundle verifier: %v", err) } - if v, err := semver.NewVersion(strings.TrimPrefix(Version, "v")); err != nil { + if v, err := semver.NewVersion(Version); err != nil { log.Printf("Failed to parse OS version %q: %v", Version, err) } else { osVersion = *v