Skip to content

Commit

Permalink
Merge pull request containers#2655 from giuseppe/tmp-user
Browse files Browse the repository at this point in the history
rootless: use /tmp/libpod-rundir-$EUID for fallback
  • Loading branch information
openshift-merge-robot committed Mar 15, 2019
2 parents a73814c + e6a4bac commit 8aed32a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/rootless/rootless_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func GetRootlessUID() int {
u, _ := strconv.Atoi(uidEnv)
return u
}
return os.Getuid()
return os.Geteuid()
}

func tryMappingTool(tool string, pid int, hostID int, mappings []idtools.IDMap) error {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 8aed32a

Please sign in to comment.