Skip to content

Commit

Permalink
rootless: fix regression when using exec on old containers
Browse files Browse the repository at this point in the history
fallback to the previous behavior of joining only the user namespace,
when we cannot join the conmon userns+mount namespaces.

Closes: containers#2673

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Mar 27, 2019
1 parent fcbca91 commit aacc5a8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cmd/podman/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,19 @@ func execCmd(c *cliconfig.ExecValues) error {
var ret int

data, err := ioutil.ReadFile(ctr.Config().ConmonPidFile)
if err != nil {
return errors.Wrapf(err, "cannot read conmon PID file %q", ctr.Config().ConmonPidFile)
}
conmonPid, err := strconv.Atoi(string(data))
if err != nil {
return errors.Wrapf(err, "cannot parse PID %q", data)
if err == nil {
conmonPid, err := strconv.Atoi(string(data))
if err != nil {
return errors.Wrapf(err, "cannot parse PID %q", data)
}
became, ret, err = rootless.JoinDirectUserAndMountNS(uint(conmonPid))
} else {
pid, err := ctr.PID()
if err != nil {
return err
}
became, ret, err = rootless.JoinNS(uint(pid), c.PreserveFDs)
}
became, ret, err = rootless.JoinDirectUserAndMountNS(uint(conmonPid))
if err != nil {
return err
}
Expand Down

0 comments on commit aacc5a8

Please sign in to comment.