[lxc-devel] [lxd/master] shared: fix $SNAP handling under new snappy

cyphar on Github lxc-bot at linuxcontainers.org
Wed May 8 01:38:28 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 549 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190507/d1e01459/attachment.bin>
-------------- next part --------------
From fb38532b0327d31955a367d8c3dc375feebae2c5 Mon Sep 17 00:00:00 2001
From: Aleksa Sarai <cyphar at cyphar.com>
Date: Wed, 8 May 2019 11:33:57 +1000
Subject: [PATCH] shared: fix $SNAP handling under new snappy

The $SNAP environment variable used to signal that LXD is running inside
a snap can be empty, which results in HostPath being a no-op inside a
snap. Instead we just use os.LookupEnv.

Signed-off-by: Aleksa Sarai <cyphar at cyphar.com>
---
 shared/util.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/shared/util.go b/shared/util.go
index 4f98cbbb26..fb03e2ee4a 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -120,9 +120,9 @@ func HostPath(path string) string {
 	}
 
 	// Check if we're running in a snap package
-	snap := os.Getenv("SNAP")
+	_, inSnap := os.LookupEnv("SNAP")
 	snapName := os.Getenv("SNAP_NAME")
-	if snap == "" || snapName != "lxd" {
+	if !inSnap || snapName != "lxd" {
 		return path
 	}
 


More information about the lxc-devel mailing list