b4813f2841
/tmp is often a tmpfs file system and large temporary files could cause docker commands to fail. Also using /tmp potentially allows users on the system to get access to content, or even attack the content. Moving the tmpdir to /var/lib/container/tmp will protect the data. Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan) Conflicts: docker/docker.go
18 lines
398 B
Go
18 lines
398 B
Go
// +build darwin dragonfly freebsd linux netbsd openbsd
|
|
|
|
package utils
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// TempDir returns the default directory to use for temporary files.
|
|
func TempDir(rootDir string) (string, error) {
|
|
var tmpDir string
|
|
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
|
|
tmpDir = filepath.Join(rootDir, "tmp")
|
|
}
|
|
err := os.MkdirAll(tmpDir, 0700)
|
|
return tmpDir, err
|
|
}
|