github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/daemon/logger/gcplogs/gcplogging_linux.go (about) 1 // +build linux 2 3 package gcplogs 4 5 import ( 6 "os" 7 8 "github.com/Sirupsen/logrus" 9 "github.com/docker/docker/dockerversion" 10 "github.com/docker/docker/pkg/homedir" 11 ) 12 13 // ensureHomeIfIAmStatic ensure $HOME to be set if dockerversion.IAmStatic is "true". 14 // See issue #29344: gcplogs segfaults (static binary) 15 // If HOME is not set, logging.NewClient() will call os/user.Current() via oauth2/google. 16 // However, in static binary, os/user.Current() leads to segfault due to a glibc issue that won't be fixed 17 // in a short term. (golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341) 18 // So we forcibly set HOME so as to avoid call to os/user/Current() 19 func ensureHomeIfIAmStatic() error { 20 // Note: dockerversion.IAmStatic and homedir.GetStatic() is only available for linux. 21 // So we need to use them in this gcplogging_linux.go rather than in gcplogging.go 22 if dockerversion.IAmStatic == "true" && os.Getenv("HOME") == "" { 23 home, err := homedir.GetStatic() 24 if err != nil { 25 return err 26 } 27 logrus.Warnf("gcplogs requires HOME to be set for static daemon binary. Forcibly setting HOME to %s.", home) 28 os.Setenv("HOME", home) 29 } 30 return nil 31 }