mirror of https://github.com/containers/podman.git
rootless, exec: use the new function to join the userns
since we have a way for joining an existing userns use it instead of nsenter. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1371 Approved by: rhatdan
This commit is contained in:
parent
2ed79f6315
commit
46acded58d
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
||||
|
@ -84,6 +85,18 @@ func execCmd(c *cli.Context) error {
|
|||
return errors.Wrapf(err, "unable to exec into %s", args[0])
|
||||
}
|
||||
|
||||
pid, err := ctr.PID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
became, ret, err := rootless.JoinNS(uint(pid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if became {
|
||||
os.Exit(ret)
|
||||
}
|
||||
|
||||
// ENVIRONMENT VARIABLES
|
||||
env := defaultEnvVariables
|
||||
for _, e := range c.StringSlice("env") {
|
||||
|
|
|
@ -691,15 +691,6 @@ func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty
|
|||
logrus.Debugf("Starting runtime %s with following arguments: %v", r.path, args)
|
||||
|
||||
execCmd := exec.Command(r.path, args...)
|
||||
if rootless.IsRootless() {
|
||||
args = append([]string{"--preserve-credentials", "--user=/proc/self/fd/3", r.path}, args...)
|
||||
f, err := rootless.GetUserNSForPid(uint(c.state.PID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
execCmd = exec.Command("nsenter", args...)
|
||||
execCmd.ExtraFiles = append(execCmd.ExtraFiles, f)
|
||||
}
|
||||
execCmd.Stdout = os.Stdout
|
||||
execCmd.Stderr = os.Stderr
|
||||
execCmd.Stdin = os.Stdin
|
||||
|
|
Loading…
Reference in New Issue