mirror of
https://github.com/containers/podman.git
synced 2025-06-25 03:52:15 +08:00
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:
@ -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
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user