Handle empty values for XDG_RUNTIME_DIR properly.

Fixes #6849

PiperOrigin-RevId: 413322019
This commit is contained in:
Ian Lewis
2021-11-30 22:18:11 -08:00
committed by gVisor bot
parent a68a8e716b
commit 72e222cd66
+2 -1
View File
@@ -126,7 +126,8 @@ func NewFromFlags() (*Config, error) {
if len(conf.RootDir) == 0 {
// If not set, set default root dir to something (hopefully) user-writeable.
conf.RootDir = "/var/run/runsc"
if runtimeDir, ok := os.LookupEnv("XDG_RUNTIME_DIR"); ok {
// NOTE: empty values for XDG_RUNTIME_DIR should be ignored.
if runtimeDir := os.Getenv("XDG_RUNTIME_DIR"); runtimeDir != "" {
conf.RootDir = filepath.Join(runtimeDir, "runsc")
}
}