66ff12e5f7
* vendor: bump libcontainer and docker to remove Sirupsen imports * vendor: fix bad vendoring of archive package * vendor: fix api changes to cgroups in executor * vendor: fix docker api changes * vendor: update github.com/Azure/go-ansiterm to use non capitalized logrus import
46 lines
617 B
Go
46 lines
617 B
Go
// +build static_build
|
|
|
|
package dbus
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func lookupHomeDir() string {
|
|
myUid := os.Getuid()
|
|
|
|
f, err := os.Open("/etc/passwd")
|
|
if err != nil {
|
|
return "/"
|
|
}
|
|
defer f.Close()
|
|
|
|
s := bufio.NewScanner(f)
|
|
|
|
for s.Scan() {
|
|
if err := s.Err(); err != nil {
|
|
break
|
|
}
|
|
|
|
line := strings.TrimSpace(s.Text())
|
|
if line == "" {
|
|
continue
|
|
}
|
|
|
|
parts := strings.Split(line, ":")
|
|
|
|
if len(parts) >= 6 {
|
|
uid, err := strconv.Atoi(parts[2])
|
|
if err == nil && uid == myUid {
|
|
return parts[5]
|
|
}
|
|
}
|
|
}
|
|
|
|
// Default to / if we can't get a better value
|
|
return "/"
|
|
}
|