2018-02-05 16:05:59 -05:00
|
|
|
package homedir // import "github.com/docker/docker/pkg/homedir"
|
2016-12-16 04:50:14 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/idtools"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetStatic returns the home directory for the current user without calling
|
|
|
|
// os/user.Current(). This is useful for static-linked binary on glibc-based
|
|
|
|
// system, because a call to os/user.Current() in a static binary leads to
|
|
|
|
// segfault due to a glibc issue that won't be fixed in a short term.
|
|
|
|
// (#29344, golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341)
|
|
|
|
func GetStatic() (string, error) {
|
|
|
|
uid := os.Getuid()
|
|
|
|
usr, err := idtools.LookupUID(uid)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return usr.Home, nil
|
|
|
|
}
|