The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6863
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) ===
From 844c70cfb5942a1dea97a3282b21b5819cfd0633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 10 Feb 2020 15:58:38 -0500 Subject: [PATCH 1/2] shared: Add 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/shared/util.go b/shared/util.go index 43b11b495c..ffaa750b9d 100644 --- a/shared/util.go +++ b/shared/util.go @@ -106,6 +106,23 @@ func IsUnixSocket(path string) bool { return (stat.Mode() & os.ModeSocket) == os.ModeSocket } +// HostPathFollow takes a valid path (from HostPath) and resolves it +// all the way to its target or to the last which can be resolved. +func HostPathFollow(path string) string { + for { + target, err := os.Readlink(path) + if err != nil { + return path + } + + if target == path { + return path + } + + path = HostPath(target) + } +} + // HostPath returns the host path for the provided path // On a normal system, this does nothing // When inside of a snap environment, returns the real path From 0a33b7065266b1bd9b5c6c8e7297eec273fbdbcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 10 Feb 2020 15:59:10 -0500 Subject: [PATCH 2/2] lxc/file: Follow symlinks on individual file transfers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxc/file.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lxc/file.go b/lxc/file.go index 83c5255f1c..aa7167a84b 100644 --- a/lxc/file.go +++ b/lxc/file.go @@ -535,6 +535,9 @@ func (c *cmdFilePush) Run(cmd *cobra.Command, args []string) error { if f == "-" { file = os.Stdin } else { + // Follow symlinks within the snap environment. + f = shared.HostPathFollow(f) + file, err = os.Open(f) if err != nil { return err
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel