From 4415bad6fe15d3a94fc729e5200d694d17151238 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 20 Jun 2018 12:21:36 +0200 Subject: oci: set XDG_RUNTIME_DIR to the runtime from GetRootlessRuntimeDir() Signed-off-by: Giuseppe Scrivano Closes: #936 Approved by: rhatdan --- libpod/oci.go | 2 +- libpod/runtime.go | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libpod/oci.go b/libpod/oci.go index 95bebdd88..c7672a04d 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -302,7 +302,7 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string) (er // 0, 1 and 2 are stdin, stdout and stderr cmd.Env = append(r.conmonEnv, fmt.Sprintf("_OCI_SYNCPIPE=%d", 3)) cmd.Env = append(cmd.Env, fmt.Sprintf("_OCI_STARTPIPE=%d", 4)) - cmd.Env = append(cmd.Env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", os.Getenv("XDG_RUNTIME_DIR"))) + cmd.Env = append(cmd.Env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", GetRootlessRuntimeDir())) if notify, ok := os.LookupEnv("NOTIFY_SOCKET"); ok { cmd.Env = append(cmd.Env, fmt.Sprintf("NOTIFY_SOCKET=%s", notify)) } diff --git a/libpod/runtime.go b/libpod/runtime.go index 338a2b436..b840d65b0 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -177,10 +177,8 @@ var ( // GetRootlessRuntimeDir returns the runtime directory when running as non root func GetRootlessRuntimeDir() string { - hasNoEnv := false runtimeDir := os.Getenv("XDG_RUNTIME_DIR") if runtimeDir == "" { - hasNoEnv = true tmpDir := filepath.Join(os.TempDir(), "user", fmt.Sprintf("%d", os.Getuid())) os.MkdirAll(tmpDir, 0700) st, err := os.Stat(tmpDir) @@ -191,9 +189,6 @@ func GetRootlessRuntimeDir() string { if runtimeDir == "" { runtimeDir = filepath.Join(os.Getenv("HOME"), "rundir") } - if hasNoEnv { - os.Setenv("XDG_RUNTIME_DIR", runtimeDir) - } return runtimeDir } -- cgit v1.2.3-54-g00ecf