[lxc-devel] [lxd/master] lxd/proxy: Fix unix socket paths in snap

stgraber on Github lxc-bot at linuxcontainers.org
Mon Sep 10 04:01:40 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180910/d476c552/attachment.bin>
-------------- next part --------------
From 5284cfbe7260816deadda03c1e6a6a790f038189 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 9 Sep 2018 20:45:11 -0700
Subject: [PATCH] lxd/proxy: Fix unix socket paths in snap
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5009

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/proxy_device_utils.go | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/lxd/proxy_device_utils.go b/lxd/proxy_device_utils.go
index 960ed07281..d6616bc9b8 100644
--- a/lxd/proxy_device_utils.go
+++ b/lxd/proxy_device_utils.go
@@ -34,14 +34,15 @@ func setupProxyProcInfo(c container, device map[string]string) (*proxyProcInfo,
 	connectAddr := device["connect"]
 	listenAddr := device["listen"]
 
-	connectionType := strings.SplitN(connectAddr, ":", 2)[0]
-	listenerType := strings.SplitN(listenAddr, ":", 2)[0]
+	connectionFields := strings.SplitN(connectAddr, ":", 2)
+	listenerFields := strings.SplitN(listenAddr, ":", 2)
 
-	if !shared.StringInSlice(connectionType, []string{"tcp", "udp", "unix"}) {
-		return nil, fmt.Errorf("Proxy device doesn't support the connection type: %s", connectionType)
+	if !shared.StringInSlice(connectionFields[0], []string{"tcp", "udp", "unix"}) {
+		return nil, fmt.Errorf("Proxy device doesn't support the connection type: %s", connectionFields[0])
 	}
-	if !shared.StringInSlice(listenerType, []string{"tcp", "udp", "unix"}) {
-		return nil, fmt.Errorf("Proxy device doesn't support the listener type: %s", listenerType)
+
+	if !shared.StringInSlice(listenerFields[0], []string{"tcp", "udp", "unix"}) {
+		return nil, fmt.Errorf("Proxy device doesn't support the listener type: %s", listenerFields[0])
 	}
 
 	listenPid := "-1"
@@ -59,6 +60,14 @@ func setupProxyProcInfo(c container, device map[string]string) (*proxyProcInfo,
 		return nil, fmt.Errorf("Invalid binding side given. Must be \"host\" or \"container\"")
 	}
 
+	if connectionFields[0] == "unix" && !strings.HasPrefix(connectionFields[1], "@") && bindVal == "container" {
+		connectAddr = fmt.Sprintf("%s:%s", connectionFields[0], shared.HostPath(connectionFields[1]))
+	}
+
+	if listenerFields[0] == "unix" && !strings.HasPrefix(connectionFields[1], "@") && bindVal == "host" {
+		listenAddr = fmt.Sprintf("%s:%s", listenerFields[0], shared.HostPath(listenerFields[1]))
+	}
+
 	p := &proxyProcInfo{
 		listenPid:      listenPid,
 		connectPid:     connectPid,


More information about the lxc-devel mailing list