From c91c365f8860315d29a17368b78dcefb23674042 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 18 Dec 2013 11:15:09 -0700 Subject: [PATCH] Canonicalize our root path before we try using it, because we make assumptions about it not containing symlinks Fixes #3242 --- docker/docker.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docker/docker.go b/docker/docker.go index 3ee7be9876..62f71d54d0 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -9,6 +9,7 @@ import ( "github.com/dotcloud/docker/utils" "log" "os" + "path/filepath" "strings" ) @@ -69,6 +70,20 @@ func main() { flag.Usage() return } + + // Docker makes some assumptions about the "absoluteness" of flRoot + // ... so let's make sure it has no symlinks + if p, err := filepath.Abs(*flRoot); err != nil { + log.Fatalf("Unable to get absolute root (%s): %s", flRoot, err) + } else { + *flRoot = p + } + if p, err := filepath.EvalSymlinks(*flRoot); err != nil { + log.Fatalf("Unable to canonicalize root (%s): %s", flRoot, err) + } else { + *flRoot = p + } + eng, err := engine.New(*flRoot) if err != nil { log.Fatal(err)