The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6896

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 2803e499ea4a15a20f304498446b662543f5d8d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 18 Feb 2020 13:55:53 -0500
Subject: [PATCH] shared/util: Fix relative paths in HostPathFollow
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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

diff --git a/shared/util.go b/shared/util.go
index ae9da6d281..4813aa62f4 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -126,6 +126,22 @@ func HostPathFollow(path string) string {
                return path
        }
 
+       // Handle relative paths
+       if path[0] != os.PathSeparator {
+               // Use the cwd of the parent as snap-confine alters our own cwd 
on launch
+               ppid := os.Getppid()
+               if ppid < 1 {
+                       return path
+               }
+
+               pwd, err := os.Readlink(fmt.Sprintf("/proc/%d/cwd", ppid))
+               if err != nil {
+                       return path
+               }
+
+               path = filepath.Clean(strings.Join([]string{pwd, path}, 
string(os.PathSeparator)))
+       }
+
        // Rely on "readlink -m" to do the right thing.
        for {
                target, err := RunCommand("readlink", "-m", path)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to