[lxc-devel] [lxd/master] Fix target filenames for recursive push with './' as source

brauner on Github lxc-bot at linuxcontainers.org
Tue Jun 27 19:07:41 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170627/95aef6e1/attachment.bin>
-------------- next part --------------
From 9f4b901ba8b2ec93234aa1db9771a29b41fa49b9 Mon Sep 17 00:00:00 2001
From: Alberto Donato <alberto.donato at canonical.com>
Date: Tue, 27 Jun 2017 11:50:52 +0200
Subject: [PATCH 1/2] Clean source path for recursive push

Signed-off-by: Alberto Donato <alberto.donato at canonical.com>
---
 lxc/file.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxc/file.go b/lxc/file.go
index 28fdeaeeb..fbe09a9ee 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -115,6 +115,7 @@ func (c *fileCmd) recursivePullFile(d lxd.ContainerServer, container string, p s
 }
 
 func (c *fileCmd) recursivePushFile(d lxd.ContainerServer, container string, source string, target string) error {
+	source = filepath.Clean(source)
 	sourceDir, _ := filepath.Split(source)
 	sourceLen := len(sourceDir)
 

From 1f974315d51cd5133c8c94fdb6fa056e8fd01642 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 27 Jun 2017 21:03:54 +0200
Subject: [PATCH 2/2] test: add tests for ./ file push

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 test/suites/filemanip.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/suites/filemanip.sh b/test/suites/filemanip.sh
index 2ad9dd7da..7ee7aeb5c 100644
--- a/test/suites/filemanip.sh
+++ b/test/suites/filemanip.sh
@@ -34,6 +34,16 @@ test_filemanip() {
 
   lxc exec filemanip -- rm -rf /tmp/ptest/source
 
+  lxc file push -p -r "./${TEST_DIR}"/source filemanip/tmp/ptest
+
+  [ "$(lxc exec filemanip -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ]
+  [ "$(lxc exec filemanip -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ]
+  [ "$(lxc exec filemanip -- stat -c "%u" /tmp/ptest/source/another_level)" = "1000" ]
+  [ "$(lxc exec filemanip -- stat -c "%g" /tmp/ptest/source/another_level)" = "1000" ]
+  [ "$(lxc exec filemanip -- stat -c "%a" /tmp/ptest/source)" = "755" ]
+
+  lxc exec filemanip -- rm -rf /tmp/ptest/source
+
   # Special case where we are in the same directory as the one we are currently
   # created.
   oldcwd=$(pwd)


More information about the lxc-devel mailing list