From 9f13b74f4a8a88b68dc55d283ecf2f849e6eac9b Mon Sep 17 00:00:00 2001 From: "Justin Terry (VM)" Date: Tue, 31 Jul 2018 15:07:55 -0700 Subject: [PATCH] Runtime v2 absolute shim path to executable Fixes an issue where the runtime v2 was not using an absolute path to the executable but setting the .Dir field on the exec.Cmd. This causes the executable to need to be relative to .Dir but no shim is actually copied to the bundle directory that its work dir is set to. Signed-off-by: Justin Terry (VM) --- runtime/v2/shim/util.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/runtime/v2/shim/util.go b/runtime/v2/shim/util.go index 1c3fb85c0..ca028a683 100644 --- a/runtime/v2/shim/util.go +++ b/runtime/v2/shim/util.go @@ -49,14 +49,20 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, cmdAr } args = append(args, cmdArgs...) name := BinaryName(runtime) - if _, err := exec.LookPath(name); err != nil { - if eerr, ok := err.(*exec.Error); ok { + var cmdPath string + var lerr error + if cmdPath, lerr = exec.LookPath(name); lerr != nil { + if eerr, ok := lerr.(*exec.Error); ok { if eerr.Err == exec.ErrNotFound { return nil, errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name) } } } - cmd := exec.Command(name, args...) + cmdPath, err = filepath.Abs(cmdPath) + if err != nil { + return nil, err + } + cmd := exec.Command(cmdPath, args...) cmd.Dir = path cmd.Env = append(os.Environ(), "GOMAXPROCS=2") cmd.SysProcAttr = getSysProcAttr()