diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-02-28 18:41:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 18:41:28 -0500 |
commit | 4c529529bd19c3cc73f630f39bb2b8df68374ad3 (patch) | |
tree | 119fc94c898b87e2235ec50aede6497ac6ec6fb2 /vendor/github.com/godbus/dbus/v5/homedir.go | |
parent | c39dffe83db9fa3cfa6897b971956821f1bbcce2 (diff) | |
parent | 2e14c72707afc1625874b5fd4367b0bc418994a1 (diff) | |
download | podman-4c529529bd19c3cc73f630f39bb2b8df68374ad3.tar.gz podman-4c529529bd19c3cc73f630f39bb2b8df68374ad3.tar.bz2 podman-4c529529bd19c3cc73f630f39bb2b8df68374ad3.zip |
Merge pull request #13372 from ashley-cui/binarypath
Allow setting binarypath from Makefile
Diffstat (limited to 'vendor/github.com/godbus/dbus/v5/homedir.go')
-rw-r--r-- | vendor/github.com/godbus/dbus/v5/homedir.go | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/vendor/github.com/godbus/dbus/v5/homedir.go b/vendor/github.com/godbus/dbus/v5/homedir.go index 0b745f931..c44d9b5fc 100644 --- a/vendor/github.com/godbus/dbus/v5/homedir.go +++ b/vendor/github.com/godbus/dbus/v5/homedir.go @@ -2,27 +2,24 @@ package dbus import ( "os" - "sync" -) - -var ( - homeDir string - homeDirLock sync.Mutex + "os/user" ) +// Get returns the home directory of the current user, which is usually the +// value of HOME environment variable. In case it is not set or empty, os/user +// package is used. +// +// If linking statically with cgo enabled against glibc, make sure the +// osusergo build tag is used. +// +// If needing to do nss lookups, do not disable cgo or set osusergo. func getHomeDir() string { - homeDirLock.Lock() - defer homeDirLock.Unlock() - + homeDir := os.Getenv("HOME") if homeDir != "" { return homeDir } - - homeDir = os.Getenv("HOME") - if homeDir != "" { - return homeDir + if u, err := user.Current(); err == nil { + return u.HomeDir } - - homeDir = lookupHomeDir() - return homeDir + return "/" } |