[lxc-devel] [lxd/master] Fix lxc exec when using a container inside a project

freeekanayaka on Github lxc-bot at linuxcontainers.org
Fri Oct 19 12:15:53 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 377 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181019/d43a0207/attachment.bin>
-------------- next part --------------
From f01c2e2b1ad7fa0aa8ad480c373422bdbd9f9a95 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Fri, 19 Oct 2018 14:14:46 +0200
Subject: [PATCH] Fix lxc exec when using a container inside a project

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/container_lxc.go    | 3 ++-
 test/suites/projects.sh | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 8b6c9d4fa6..1d13d0d85e 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -5983,7 +5983,8 @@ func (c *containerLXC) Exec(command []string, env map[string]string, stdin *os.F
 	}
 
 	// Prepare the subcommand
-	args := []string{c.state.OS.ExecPath, "forkexec", c.name, c.state.OS.LxcPath, filepath.Join(c.LogPath(), "lxc.conf")}
+	cname := projectPrefix(c.Project(), c.Name())
+	args := []string{c.state.OS.ExecPath, "forkexec", cname, c.state.OS.LxcPath, filepath.Join(c.LogPath(), "lxc.conf")}
 
 	args = append(args, "--")
 	args = append(args, "env")
diff --git a/test/suites/projects.sh b/test/suites/projects.sh
index 12b799640a..6921ec4c16 100644
--- a/test/suites/projects.sh
+++ b/test/suites/projects.sh
@@ -91,6 +91,7 @@ test_projects_containers() {
   # Start the container
   lxc start c1
   lxc list | grep c1 | grep -q RUNNING
+  lxc exec c1 /bin/ls / | grep -q linuxrc
 
   # The container can't be managed when using the default project
   lxc project switch default


More information about the lxc-devel mailing list