diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-07-05 12:03:28 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-05 13:30:15 +0000 |
commit | 4cc4c7137d29111fe6ccca526bc11d435fa20dd7 (patch) | |
tree | b990714e796192e5e0d180a5ee0540f642481323 /libpod | |
parent | a1545fe6e4749444204f27f5c04034f9415d4757 (diff) | |
download | podman-4cc4c7137d29111fe6ccca526bc11d435fa20dd7.tar.gz podman-4cc4c7137d29111fe6ccca526bc11d435fa20dd7.tar.bz2 podman-4cc4c7137d29111fe6ccca526bc11d435fa20dd7.zip |
rootless: add /run/user/$UID to the lookup paths
when XDG_RUNTIME_DIR is not set, still attempt to use /run/user/$UID
before looking up other directories.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #1048
Approved by: mheon
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 6f751f959..ce64f0d5b 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -178,8 +178,17 @@ var ( // GetRootlessRuntimeDir returns the runtime directory when running as non root func GetRootlessRuntimeDir() string { runtimeDir := os.Getenv("XDG_RUNTIME_DIR") + uid := fmt.Sprintf("%d", rootless.GetRootlessUID()) if runtimeDir == "" { - tmpDir := filepath.Join(os.TempDir(), "user", fmt.Sprintf("%d", os.Getuid())) + tmpDir := filepath.Join("/run", "user", uid) + os.MkdirAll(tmpDir, 0700) + st, err := os.Stat(tmpDir) + if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Getuid() && st.Mode().Perm() == 0700 { + runtimeDir = tmpDir + } + } + if runtimeDir == "" { + tmpDir := filepath.Join(os.TempDir(), "user", uid) os.MkdirAll(tmpDir, 0700) st, err := os.Stat(tmpDir) if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Getuid() && st.Mode().Perm() == 0700 { |