Update shim exec rpc to take fewer args
Signed-off-by: Ophir Sneh <otsneh@gmail.com>
This commit is contained in:
parent
fa71fc91fa
commit
87f94bf79b
4 changed files with 115 additions and 496 deletions
|
@ -2,6 +2,7 @@ package shim
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -57,7 +58,15 @@ func newExecProcess(context context.Context, r *shimapi.ExecRequest, parent *ini
|
|||
IO: io,
|
||||
Detach: true,
|
||||
}
|
||||
if err := parent.runc.Exec(context, parent.id, processFromRequest(r), opts); err != nil {
|
||||
|
||||
// process exec request
|
||||
var spec specs.Process
|
||||
if err := json.Unmarshal(r.Spec.Value, &spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
spec.Terminal = r.Terminal
|
||||
|
||||
if err := parent.runc.Exec(context, parent.id, spec, opts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if socket != nil {
|
||||
|
@ -82,27 +91,6 @@ func newExecProcess(context context.Context, r *shimapi.ExecRequest, parent *ini
|
|||
return e, nil
|
||||
}
|
||||
|
||||
func processFromRequest(r *shimapi.ExecRequest) specs.Process {
|
||||
var user specs.User
|
||||
if r.User != nil {
|
||||
user.UID = r.User.Uid
|
||||
user.GID = r.User.Gid
|
||||
user.AdditionalGids = r.User.AdditionalGids
|
||||
}
|
||||
return specs.Process{
|
||||
Terminal: r.Terminal,
|
||||
User: user,
|
||||
Rlimits: rlimits(r.Rlimits),
|
||||
Args: r.Args,
|
||||
Env: r.Env,
|
||||
Cwd: r.Cwd,
|
||||
Capabilities: r.Capabilities,
|
||||
NoNewPrivileges: r.NoNewPrivileges,
|
||||
ApparmorProfile: r.ApparmorProfile,
|
||||
SelinuxLabel: r.SelinuxLabel,
|
||||
}
|
||||
}
|
||||
|
||||
func rlimits(rr []*shimapi.Rlimit) (o []specs.LinuxRlimit) {
|
||||
for _, r := range rr {
|
||||
o = append(o, specs.LinuxRlimit{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue