[lxc-devel] [lxd/master] clean the given source filepath
wagoodman on Github
lxc-bot at linuxcontainers.org
Sun Jun 25 16:59:57 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 509 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170625/b4e11f6c/attachment.bin>
-------------- next part --------------
From 3247f2f266099dc4ffca3d187725e42d4d184be2 Mon Sep 17 00:00:00 2001
From: wagoodman <wagoodman at gmail.com>
Date: Sun, 25 Jun 2017 12:53:19 -0400
Subject: [PATCH] clean the given source filepath
Signed-off-by: wagoodman <wagoodman at gmail.com>
---
client.go | 5 +----
lxc/file.go | 3 ++-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/client.go b/client.go
index 77a3890bb..4694caca6 100644
--- a/client.go
+++ b/client.go
@@ -1873,9 +1873,6 @@ func (c *Client) RecursivePushFile(container string, source string, target strin
return fmt.Errorf("This function isn't supported by public remotes.")
}
- sourceDir, _ := filepath.Split(source)
- sourceLen := len(sourceDir)
-
sendFile := func(p string, fInfo os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("Failed to walk path for %s: %s", p, err)
@@ -1886,7 +1883,7 @@ func (c *Client) RecursivePushFile(container string, source string, target strin
return fmt.Errorf("'%s' isn't a regular file or directory.", p)
}
- targetPath := path.Join(target, filepath.ToSlash(p[sourceLen:]))
+ targetPath := path.Join(target, filepath.ToSlash(p))
if fInfo.IsDir() {
mode, uid, gid := shared.GetOwnerMode(fInfo)
return c.Mkdir(container, targetPath, mode, uid, gid)
diff --git a/lxc/file.go b/lxc/file.go
index 67ecbaf03..96d60ac52 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -102,7 +102,8 @@ func (c *fileCmd) push(config *lxd.Config, send_file_perms bool, args []string)
var sourcefilenames []string
for _, fname := range args[:len(args)-1] {
- if !strings.HasPrefix(fname, "--") {
+ if !strings.HasPrefix(fname, "--")
+ fname = path.Clean(fname)
sourcefilenames = append(sourcefilenames, fname)
}
}
More information about the lxc-devel
mailing list