From 334aea3441d9e499b7f999098a16abcb81d16a68 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Mon, 16 Mar 2015 15:54:35 -0400 Subject: [PATCH] Fix relative path execution of docker daemon in reexec.Self() After the new libcontainer API, the reexec.Self() output of the daemon binary is used as the libcontainer factory InitPath. If it is relative, it can't be found at container start time. This patch solves the problem by making sure that we return a rooted/absolute path if a relative path is used. Docker-DCO-1.1-Signed-off-by: Phil Estes (github: estesp) --- pkg/reexec/reexec.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/reexec/reexec.go b/pkg/reexec/reexec.go index 774e71c76d..a5f01a26e3 100644 --- a/pkg/reexec/reexec.go +++ b/pkg/reexec/reexec.go @@ -35,8 +35,14 @@ func Self() string { name := os.Args[0] if filepath.Base(name) == name { if lp, err := exec.LookPath(name); err == nil { - name = lp + return lp } } + // handle conversion of relative paths to absolute + if absName, err := filepath.Abs(name); err == nil { + return absName + } + // if we coudn't get absolute name, return original + // (NOTE: Go only errors on Abs() if os.Getwd fails) return name }