[lxc-devel] [lxd/master] Check for LXC version to decide which apparmor profile config key to use

freeekanayaka on Github lxc-bot at linuxcontainers.org
Tue Feb 13 06:07:16 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180213/2eea2c6d/attachment.bin>
-------------- next part --------------
From 13e07959c3c6f1a1446373dd158f49faa3e43e46 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Tue, 13 Feb 2018 06:06:16 +0000
Subject: [PATCH] Check for LXC version to decide which apparmor profile config
 key to use

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 test/suites/config.sh | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/test/suites/config.sh b/test/suites/config.sh
index 4c97391a3..aa69210c4 100644
--- a/test/suites/config.sh
+++ b/test/suites/config.sh
@@ -153,8 +153,20 @@ test_config_profiles() {
   lxc profile device add onenic eth0 nic nictype=p2p
   lxc profile assign foo onenic
   lxc profile create unconfined
-  lxc profile set unconfined raw.lxc "lxc.apparmor.profile=unconfined"
+
+  # Look at the LXC version to decide whether to use the new
+  # or the new config key for apparmor.
+  lxc_version=$(lxc info | grep "driver_version: " | cut -d' ' -f4)
+  lxc_major=$(echo "${lxc_version}" | cut -d. -f1)
+  lxc_minor=$(echo "${lxc_version}" | cut -d. -f2)
+  if [ "${lxc_major}" -lt 2 ] || ([ "${lxc_major}" = "2" ] && [ "${lxc_minor}" -lt "1" ]); then
+      lxc profile set unconfined raw.lxc "lxc.aa_profile=unconfined"
+  else
+      lxc profile set unconfined raw.lxc "lxc.apparmor.profile=unconfined"
+  fi
+
   lxc profile assign foo onenic,unconfined
+
   # test profile rename
   lxc profile create foo
   lxc profile rename foo bar


More information about the lxc-devel mailing list