diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-03-14 20:32:12 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-03-15 10:39:23 +0100 |
commit | 592a2fd544d550a310c7fec2357bad3a00326486 (patch) | |
tree | 583e61314f2a7dae5c096a004fb624833d8a15fc | |
parent | 39859850aec4d0d3fe8bcf7804f6f02a245e2b6e (diff) | |
download | podman-592a2fd544d550a310c7fec2357bad3a00326486.tar.gz podman-592a2fd544d550a310c7fec2357bad3a00326486.tar.bz2 podman-592a2fd544d550a310c7fec2357bad3a00326486.zip |
rootless: use /tmp/libpod-rundir-$EUID for fallback
when the fallback is in place, the first user creating /tmp/user/$EUID
prevents other users for creating other directories since /tmp/user is
created with mode 0700.
Since there is no way for an unprivileged user to initialize the
/tmp/user directory correctly (we would need it to be owned by root
with the sticky bit set), let's just use /tmp/libpod-rundir-$EUID.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r-- | pkg/util/utils.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go index d7e1ddd38..73dddf2ac 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -190,15 +190,15 @@ func GetRootlessRuntimeDir() (string, error) { 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 { + if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Geteuid() && st.Mode().Perm() == 0700 { runtimeDir = tmpDir } } if runtimeDir == "" { - tmpDir := filepath.Join(os.TempDir(), "user", uid) + tmpDir := filepath.Join(os.TempDir(), fmt.Sprintf("libpod-rundir-%s", 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 { + if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Geteuid() && st.Mode().Perm() == 0700 { runtimeDir = tmpDir } } |