rootless: fix regression when using exec on old containers

fallback to the previous behavior of joining only the user namespace,
when we cannot join the conmon userns+mount namespaces.

Closes: https://github.com/containers/libpod/issues/2673

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-03-25 23:15:24 +01:00
parent fcbca91dca
commit aacc5a8632

View File

@ -112,14 +112,19 @@ func execCmd(c *cliconfig.ExecValues) error {
var ret int var ret int
data, err := ioutil.ReadFile(ctr.Config().ConmonPidFile) data, err := ioutil.ReadFile(ctr.Config().ConmonPidFile)
if err != nil { if err == nil {
return errors.Wrapf(err, "cannot read conmon PID file %q", ctr.Config().ConmonPidFile)
}
conmonPid, err := strconv.Atoi(string(data)) conmonPid, err := strconv.Atoi(string(data))
if err != nil { if err != nil {
return errors.Wrapf(err, "cannot parse PID %q", data) return errors.Wrapf(err, "cannot parse PID %q", data)
} }
became, ret, err = rootless.JoinDirectUserAndMountNS(uint(conmonPid)) 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)
}
if err != nil { if err != nil {
return err return err
} }