github.com/cdoern/storage@v1.12.13/pkg/homedir/homedir_linux.go (about) 1 // +build linux 2 3 package homedir 4 5 import ( 6 "os" 7 8 "github.com/containers/storage/pkg/idtools" 9 ) 10 11 // GetStatic returns the home directory for the current user without calling 12 // os/user.Current(). This is useful for static-linked binary on glibc-based 13 // system, because a call to os/user.Current() in a static binary leads to 14 // segfault due to a glibc issue that won't be fixed in a short term. 15 // (#29344, golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341) 16 func GetStatic() (string, error) { 17 uid := os.Getuid() 18 usr, err := idtools.LookupUID(uid) 19 if err != nil { 20 return "", err 21 } 22 return usr.Home, nil 23 }