container_exec: fix terminal true process json

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-12-07 20:33:07 +01:00
parent 85f303f3ff
commit afeab27a36
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
2 changed files with 30 additions and 39 deletions

View file

@ -1,10 +1,8 @@
package server
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"time"
@ -55,28 +53,14 @@ func (ss streamService) Exec(containerID string, cmd []string, stdin io.Reader,
return fmt.Errorf("container is not created or running")
}
f, err := ioutil.TempFile("", "exec-process")
processFile, err := oci.PrepareProcessExec(c, cmd, tty)
if err != nil {
return err
}
defer os.RemoveAll(f.Name())
pspec := c.Spec().Process
pspec.Args = cmd
processJSON, err := json.Marshal(pspec)
if err != nil {
return err
}
if err := ioutil.WriteFile(f.Name(), processJSON, 0644); err != nil {
return err
}
defer os.RemoveAll(processFile.Name())
args := []string{"exec"}
if tty {
args = append(args, "-t")
}
args = append(args, "-p", f.Name())
args = append(args, "--process", processFile.Name())
args = append(args, c.ID())
execCmd := exec.Command(ss.runtimeServer.Runtime().Path(c), args...)
var cmdErr error