From 15dc75720e324a2bdd9b4a8566651fa010c10d51 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 28 Mar 2018 11:33:42 -0400 Subject: [PATCH] don't re-use a TempDir path Rather than creating and immediately removing a temp directory to get a random path name, fetch files into a subdirectory. --- config/module/get.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config/module/get.go b/config/module/get.go index 58515ab36..5073d0d27 100644 --- a/config/module/get.go +++ b/config/module/get.go @@ -3,6 +3,7 @@ package module import ( "io/ioutil" "os" + "path/filepath" "github.com/hashicorp/go-getter" ) @@ -37,13 +38,10 @@ func GetCopy(dst, src string) error { if err != nil { return err } - // FIXME: This isn't completely safe. Creating and removing our temp path - // exposes where to race to inject files. - if err := os.RemoveAll(tmpDir); err != nil { - return err - } defer os.RemoveAll(tmpDir) + tmpDir = filepath.Join(tmpDir, "module") + // Get to that temporary dir if err := getter.Get(tmpDir, src); err != nil { return err