[lxc-devel] [lxd/master] lxd-p2c: Workaround for broken /proc/self/exe

stgraber on Github lxc-bot at linuxcontainers.org
Fri Mar 15 16:44:39 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 540 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190315/115ae2f2/attachment.bin>
-------------- next part --------------
From 08ebe32b33464752f66733048bd6258dc5deb38d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 15 Mar 2019 12:10:38 -0400
Subject: [PATCH] lxd-p2c: Workaround for broken /proc/self/exe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Apparently some systems sometimes return garbage in that path even for
what shouldn't be a deleted file.

In such cases, just use os.Args[0] and hope for the best.

Closes #5555

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

diff --git a/lxd-p2c/transfer.go b/lxd-p2c/transfer.go
index 4fb3068f5e..aa1d9f1038 100644
--- a/lxd-p2c/transfer.go
+++ b/lxd-p2c/transfer.go
@@ -65,6 +65,10 @@ func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.Read
 		return nil, nil, nil, err
 	}
 
+	if (!shared.PathExists(execPath)) {
+		execPath = os.Args[0]
+	}
+
 	rsyncCmd := fmt.Sprintf("sh -c \"%s netcat %s\"", execPath, auds)
 
 	args := []string{


More information about the lxc-devel mailing list