From 075abfeeaed5f9b884bd0ec18edda8f9d1bec213 Mon Sep 17 00:00:00 2001 From: Godefroid Chapelle Date: Tue, 2 Dec 2014 14:58:13 +0100 Subject: [PATCH 1/3] Escapes cp alias Fix for #1656 --- builder/docker/communicator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 36ba291d3..0956c82f2 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -75,7 +75,7 @@ func (c *Communicator) Upload(dst string, src io.Reader, fi *os.FileInfo) error // Copy the file into place by copying the temporary file we put // into the shared folder into the proper location in the container cmd := &packer.RemoteCmd{ - Command: fmt.Sprintf("cp %s/%s %s", c.ContainerDir, + Command: fmt.Sprintf("\cp %s/%s %s", c.ContainerDir, filepath.Base(tempfile.Name()), dst), } From 955122f2e1d4048c6f35c145d283d531de76da31 Mon Sep 17 00:00:00 2001 From: Godefroid Chapelle Date: Tue, 2 Dec 2014 15:07:29 +0100 Subject: [PATCH 2/3] Be more explicit about escaping alias --- builder/docker/communicator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 0956c82f2..4c5b5043e 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -75,7 +75,7 @@ func (c *Communicator) Upload(dst string, src io.Reader, fi *os.FileInfo) error // Copy the file into place by copying the temporary file we put // into the shared folder into the proper location in the container cmd := &packer.RemoteCmd{ - Command: fmt.Sprintf("\cp %s/%s %s", c.ContainerDir, + Command: fmt.Sprintf("command cp %s/%s %s", c.ContainerDir, filepath.Base(tempfile.Name()), dst), } From f52283d78e1ef9d49deba57e565d2e23d9a19888 Mon Sep 17 00:00:00 2001 From: Godefroid Chapelle Date: Mon, 22 Dec 2014 12:58:41 +0100 Subject: [PATCH 3/3] all calls to cp should be escaped --- builder/docker/communicator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 4c5b5043e..bad2c1ff6 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -166,7 +166,7 @@ func (c *Communicator) UploadDir(dst string, src string, exclude []string) error // Make the directory, then copy into it cmd := &packer.RemoteCmd{ - Command: fmt.Sprintf("set -e; mkdir -p %s; cp -R %s/* %s", + Command: fmt.Sprintf("set -e; mkdir -p %s; command cp -R %s/* %s", containerDst, containerSrc, containerDst), } if err := c.Start(cmd); err != nil {