The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2567
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) === Prepending / on windows seems like a bad idea ;) Closes #2565 Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From 8997c8458d402d312eb3e7f86d2fceafbde35892 Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Wed, 26 Oct 2016 11:20:20 -0600 Subject: [PATCH] only normalize paths on linux Prepending / on windows seems like a bad idea ;) Closes #2565 Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- lxc/file.go | 11 +---------- lxc/file_unix.go | 16 ++++++++++++++++ lxc/file_windows.go | 4 ++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lxc/file.go b/lxc/file.go index f610f5f..82050a6 100644 --- a/lxc/file.go +++ b/lxc/file.go @@ -74,16 +74,7 @@ func (c *fileCmd) push(config *lxd.Config, send_file_perms bool, args []string) return fmt.Errorf(i18n.G("Invalid target %s"), target) } - /* Fix up the path. Let's: - * 1. re-add the leading / that got stripped from the SplitN - * 2. clean it and remove any /./, /../, /////, etc. - * 3. keep the trailing slash if it had one, since we use it via - * filepath.Split below - */ - pathSpec[1] = filepath.Clean("/" + pathSpec[1]) - if target[len(target)-1] == '/' { - pathSpec[1] = pathSpec[1] + "/" - } + pathSpec[1] = c.normalize(pathSpec[1], target) targetPath := pathSpec[1] remote, container := config.ParseRemoteAndContainer(pathSpec[0]) diff --git a/lxc/file_unix.go b/lxc/file_unix.go index 1cc6aba..ba70c45 100644 --- a/lxc/file_unix.go +++ b/lxc/file_unix.go @@ -4,6 +4,7 @@ package main import ( "os" + "path/filepath" "syscall" ) @@ -19,3 +20,18 @@ func (c *fileCmd) getOwner(f *os.File) (os.FileMode, int, int, error) { return mode, uid, gid, nil } + +func (c *fileCmd) normalize(path string, target string) string { + /* Fix up the path. Let's: + * 1. re-add the leading / that got stripped from the SplitN + * 2. clean it and remove any /./, /../, /////, etc. + * 3. keep the trailing slash if it had one, since we use it via + * filepath.Split below + */ + path = filepath.Clean("/" + path) + if target[len(target)-1] == '/' { + path = path + "/" + } + + return path +} diff --git a/lxc/file_windows.go b/lxc/file_windows.go index c3bf927..583a518 100644 --- a/lxc/file_windows.go +++ b/lxc/file_windows.go @@ -9,3 +9,7 @@ import ( func (c *fileCmd) getOwner(f *os.File) (os.FileMode, int, int, error) { return os.FileMode(0), -1, -1, nil } + +func (c *fileCmd) normalize(path string, target string) string { + return path +}
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel