oci: make explicit the extra files to the exec

In the previous version I forgot to add the fds to preserve into
AdditionalFiles.  It doesn't make a difference as the files were still
preserved, but this seems to be the correct way of making it
explicit.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-03-07 15:16:25 +01:00
parent ea031be2df
commit ffe1ed7058
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
1 changed files with 6 additions and 0 deletions

View File

@ -805,6 +805,12 @@ func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty
execCmd.Env = append(execCmd.Env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
if preserveFDs > 0 {
for fd := 3; fd < 3+preserveFDs; fd++ {
execCmd.ExtraFiles = append(execCmd.ExtraFiles, os.NewFile(uintptr(fd), fmt.Sprintf("fd-%d", fd)))
}
}
if err := execCmd.Start(); err != nil {
return nil, errors.Wrapf(err, "cannot start container %s", c.ID())
}