Ensure the temp directory exists before trying to make a directory in it

This commit is contained in:
Dane Everitt 2020-05-03 21:04:16 -07:00
parent b2797ed292
commit ac011214f7
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -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)