From ac011214f784b4386630cfa764cd2005f78d3abf Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 3 May 2020 21:04:16 -0700 Subject: [PATCH] Ensure the temp directory exists before trying to make a directory in it --- server/install.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/install.go b/server/install.go index f8ac734..995329f 100644 --- a/server/install.go +++ b/server/install.go @@ -15,6 +15,7 @@ import ( "io" "io/ioutil" "os" + "path" "path/filepath" "sync" ) @@ -131,6 +132,12 @@ func (ip *InstallationProcess) Run() error { // Writes the installation script to a temporary file on the host machine so that it // can be properly mounted into the installation container and then executed. func (ip *InstallationProcess) writeScriptToDisk() (string, error) { + // Make sure the temp directory root exists before trying to make a directory within it. The + // ioutil.TempDir call expects this base to exist, it won't create it for you. + if err := os.MkdirAll(path.Join(os.TempDir(), "pterodactyl/"), 0700); err != nil { + return "", errors.WithStack(err) + } + d, err := ioutil.TempDir("", "pterodactyl/") if err != nil { return "", errors.WithStack(err)