From 4700b961ca4108b44d806bda55a629260e129a32 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 10 Mar 2016 23:08:54 -0800 Subject: [PATCH] Fix userns mapping for tty - Linux part of the spec was ignored - Exec used empty spec Signed-off-by: Tonis Tiigi --- runtime/container.go | 2 +- runtime/container_linux.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/container.go b/runtime/container.go index 619200d..3920523 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -193,7 +193,7 @@ func (c *container) readSpec() (*specs.PlatformSpec, error) { return nil, err } defer f.Close() - if err := json.NewDecoder(f).Decode(&spec.Spec); err != nil { + if err := json.NewDecoder(f).Decode(&spec); err != nil { return nil, err } return &spec, nil diff --git a/runtime/container_linux.go b/runtime/container_linux.go index 77c8d39..734f5a0 100644 --- a/runtime/container_linux.go +++ b/runtime/container_linux.go @@ -166,7 +166,7 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) { return p, nil } -func (c *container) Exec(pid string, spec specs.ProcessSpec, s Stdio) (Process, error) { +func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (Process, error) { processRoot := filepath.Join(c.root, c.id, pid) if err := os.Mkdir(processRoot, 0755); err != nil { return nil, err @@ -178,12 +178,17 @@ func (c *container) Exec(pid string, spec specs.ProcessSpec, s Stdio) (Process, cmd.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, } + spec, err := c.readSpec() + if err != nil { + return nil, err + } config := &processConfig{ exec: true, id: pid, root: processRoot, c: c, - processSpec: spec, + processSpec: pspec, + spec: spec, stdio: s, } p, err := newProcess(config)