From d5c5306a97b648ded06a8eb76ce728f07c9924f0 Mon Sep 17 00:00:00 2001 From: Matthew Patton Date: Wed, 31 Oct 2018 20:11:36 -0400 Subject: [PATCH] close massive file overwrite hole with TempDir --- helper/common/shared_state.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helper/common/shared_state.go b/helper/common/shared_state.go index 87e111cfb..88ddf0aaa 100644 --- a/helper/common/shared_state.go +++ b/helper/common/shared_state.go @@ -7,11 +7,16 @@ import ( "path/filepath" ) +var sharedStateDir := ioutil.TempDir(packer.ConfigTmpDir(), "state") + // Used to set variables which we need to access later in the build, where // state bag and config information won't work func sharedStateFilename(suffix string, buildName string) string { uuid := os.Getenv("PACKER_RUN_UUID") - return filepath.Join(os.TempDir(), fmt.Sprintf("packer-%s-%s-%s", uuid, suffix, buildName)) + if uuid == "" { + uuid="none" + } + return filepath.Join(sharedStateDir, fmt.Sprintf("%s-%s-%s", uuid, suffix, buildName)) } func SetSharedState(key string, value string, buildName string) error {