|
@@ -11,17 +11,15 @@ import (
|
|
// ensureHomeIfIAmStatic ensure $HOME to be set if dockerversion.IAmStatic is "true".
|
|
// ensureHomeIfIAmStatic ensure $HOME to be set if dockerversion.IAmStatic is "true".
|
|
// See issue #29344: gcplogs segfaults (static binary)
|
|
// See issue #29344: gcplogs segfaults (static binary)
|
|
// If HOME is not set, logging.NewClient() will call os/user.Current() via oauth2/google.
|
|
// If HOME is not set, logging.NewClient() will call os/user.Current() via oauth2/google.
|
|
-// However, in static binary, os/user.Current() leads to segfault due to a glibc issue that won't be fixed
|
|
|
|
-// in a short term. (golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341)
|
|
|
|
|
|
+// If compiling statically, make sure osusergo build tag is also used to prevent a segfault
|
|
|
|
+// due to a glibc issue that won't be fixed in a short term
|
|
|
|
+// (see golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341).
|
|
// So we forcibly set HOME so as to avoid call to os/user/Current()
|
|
// So we forcibly set HOME so as to avoid call to os/user/Current()
|
|
func ensureHomeIfIAmStatic() error {
|
|
func ensureHomeIfIAmStatic() error {
|
|
- // Note: dockerversion.IAmStatic and homedir.GetStatic() is only available for linux.
|
|
|
|
|
|
+ // Note: dockerversion.IAmStatic is only available for linux.
|
|
// So we need to use them in this gcplogging_linux.go rather than in gcplogging.go
|
|
// So we need to use them in this gcplogging_linux.go rather than in gcplogging.go
|
|
if dockerversion.IAmStatic == "true" && os.Getenv("HOME") == "" {
|
|
if dockerversion.IAmStatic == "true" && os.Getenv("HOME") == "" {
|
|
- home, err := homedir.GetStatic()
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
|
|
+ home := homedir.Get()
|
|
logrus.Warnf("gcplogs requires HOME to be set for static daemon binary. Forcibly setting HOME to %s.", home)
|
|
logrus.Warnf("gcplogs requires HOME to be set for static daemon binary. Forcibly setting HOME to %s.", home)
|
|
os.Setenv("HOME", home)
|
|
os.Setenv("HOME", home)
|
|
}
|
|
}
|