[lxc-devel] [lxd/master] If running as root in the snap, use /proc/1/root

stgraber on Github lxc-bot at linuxcontainers.org
Mon Oct 23 16:27:57 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171023/6104afaf/attachment.bin>
-------------- next part --------------
From ba4c0c8b397217ef3086cd2a5cc06131e394c635 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 23 Oct 2017 18:11:00 +0200
Subject: [PATCH] If running as root in the snap, use /proc/1/root
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/util.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/shared/util.go b/shared/util.go
index ac32d967c..e97b2db09 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -143,6 +143,10 @@ func HostPath(path string) string {
 		}
 	}
 
+	if os.Geteuid() == 0 {
+		return fmt.Sprintf("/proc/1/root%s", path)
+	}
+
 	return fmt.Sprintf("/var/lib/snapd/hostfs%s", path)
 }
 


More information about the lxc-devel mailing list