From 3c9f9945c949e981a4c09da915ea28356b2c58ae Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 14 Aug 2013 10:26:18 +0000 Subject: [PATCH] prevent crash when .dockercfg not readable --- auth/auth.go | 2 +- commands.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index b9e1ee153b..003a6e737c 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -80,7 +80,7 @@ func LoadConfig(rootPath string) (*ConfigFile, error) { } b, err := ioutil.ReadFile(confFile) if err != nil { - return nil, err + return &configFile, err } if err := json.Unmarshal(b, &configFile.Configs); err != nil { diff --git a/commands.go b/commands.go index e920aa3c4a..6f5c3bc1f4 100644 --- a/commands.go +++ b/commands.go @@ -1751,7 +1751,10 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, proto, addr string) *Doc err = out } - configFile, _ := auth.LoadConfig(os.Getenv("HOME")) + configFile, e := auth.LoadConfig(os.Getenv("HOME")) + if e != nil { + fmt.Fprintf(err, "WARNING: %s\n", e) + } return &DockerCli{ proto: proto, addr: addr,