Skip to content

Commit 9dc55ea

Browse files
authored
Merge pull request #2514 from jterry75/runtime_v2_shim_command
Runtime v2 absolute shim path to executable
2 parents 875b92c + 9f13b74 commit 9dc55ea

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

runtime/v2/shim/util.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,20 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, cmdAr
4949
}
5050
args = append(args, cmdArgs...)
5151
name := BinaryName(runtime)
52-
if _, err := exec.LookPath(name); err != nil {
53-
if eerr, ok := err.(*exec.Error); ok {
52+
var cmdPath string
53+
var lerr error
54+
if cmdPath, lerr = exec.LookPath(name); lerr != nil {
55+
if eerr, ok := lerr.(*exec.Error); ok {
5456
if eerr.Err == exec.ErrNotFound {
5557
return nil, errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name)
5658
}
5759
}
5860
}
59-
cmd := exec.Command(name, args...)
61+
cmdPath, err = filepath.Abs(cmdPath)
62+
if err != nil {
63+
return nil, err
64+
}
65+
cmd := exec.Command(cmdPath, args...)
6066
cmd.Dir = path
6167
cmd.Env = append(os.Environ(), "GOMAXPROCS=2")
6268
cmd.SysProcAttr = getSysProcAttr()

0 commit comments

Comments
 (0)