[lxc-devel] [lxd/master] lxd/dameon: Add LXD_EXEC_PATH to override execPath
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Nov 21 04:22:55 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 800 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171121/0167fd6a/attachment.bin>
-------------- next part --------------
From 1aee50f0386481c55ac8c6bb8615bf3e716701d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 20 Nov 2017 23:20:12 -0500
Subject: [PATCH] lxd/dameon: Add LXD_EXEC_PATH to override execPath
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is needed for the LXD snap.
The pre-start/post-stop container hooks point to the LXD path and are
called when the container shuts down.
As the snapd paths include the revision of the daemon, a system which
got updated would then have a hook path pointing to a non-existing
binary.
This extra env variable allows us to point to the "current" path in the
snap, which is effectively a symlink to whichever is the latest binary.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
doc/environment.md | 3 ++-
lxd/util/sys.go | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/doc/environment.md b/doc/environment.md
index e20ae9c79..fae35be81 100644
--- a/doc/environment.md
+++ b/doc/environment.md
@@ -20,5 +20,6 @@ Name | Description
# Server environment variable
Name | Description
:--- | :----
-`LXD_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off
+`LXD_EXEC_PATH` | Full path to the LXD binary (used when forking subcommands)
`LXD_LXC_TEMPLATE_CONFIG` | Path to the LXC template configuration directory
+`LXD_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off
diff --git a/lxd/util/sys.go b/lxd/util/sys.go
index a9d91f634..5532f8704 100644
--- a/lxd/util/sys.go
+++ b/lxd/util/sys.go
@@ -152,6 +152,11 @@ func RuntimeLiblxcVersionAtLeast(major int, minor int, micro int) bool {
}
func GetExecPath() string {
+ execPath := os.Getenv("LXD_EXEC_PATH")
+ if execPath != "" {
+ return execPath
+ }
+
execPath, err := os.Readlink("/proc/self/exe")
if err != nil {
execPath = "bad-exec-path"
More information about the lxc-devel
mailing list