[lxc-devel] [lxd/master] lxd/apparmor: Fix version parsing

monstermunchkin on Github lxc-bot at linuxcontainers.org
Tue Oct 6 09:06:22 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 491 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201006/3b0d22bb/attachment.bin>
-------------- next part --------------
From d02107da5e37a6e4c397d71290e083b31f2773a3 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Tue, 6 Oct 2020 10:58:31 +0200
Subject: [PATCH] lxd/apparmor: Fix version parsing

Instead of using NewDottedVersion(), use Parse() which can handle
version strings containing suffixes, e.g. "3.0.0-beta1" or similar.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 lxd/apparmor/apparmor.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/apparmor/apparmor.go b/lxd/apparmor/apparmor.go
index 2231964633..9d8ec55f46 100644
--- a/lxd/apparmor/apparmor.go
+++ b/lxd/apparmor/apparmor.go
@@ -203,7 +203,7 @@ func getVersion(state *state.State) (*version.DottedVersion, error) {
 	}
 
 	fields := strings.Fields(strings.Split(out, "\n")[0])
-	return version.NewDottedVersion(fields[len(fields)-1])
+	return version.Parse(fields[len(fields)-1])
 }
 
 // getCacheDir returns the applicable AppArmor cache directory.


More information about the lxc-devel mailing list