Use user-specific temp directory if set
This allows non-privileged users to use containerd. This is part of a larger track of work integrating containerd into Cloudfoundry's garden with support for rootless. [#156343575] Signed-off-by: Claudia Beresford <cberesford@pivotal.io>
This commit is contained in:
committed by
Claudia Beresford
parent
40c3acd36c
commit
fc8bce59b9
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var tempMountLocation = os.TempDir()
|
||||
var tempMountLocation = getTempDir()
|
||||
|
||||
// WithTempMount mounts the provided mounts to a temp dir, and pass the temp dir to f.
|
||||
// The mounts are valid during the call to the f.
|
||||
@@ -64,3 +64,10 @@ func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) erro
|
||||
}
|
||||
return errors.Wrapf(f(root), "mount callback failed on %s", root)
|
||||
}
|
||||
|
||||
func getTempDir() string {
|
||||
if xdg := os.Getenv("XDG_RUNTIME_DIR"); xdg != "" {
|
||||
return xdg
|
||||
}
|
||||
return os.TempDir()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user