diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2019-11-09 23:23:30 +0000 |
---|---|---|
committer | Radostin Stoyanov <rstoyanov1@gmail.com> | 2019-11-17 00:34:02 +0000 |
commit | 368d2ecfb6ee618803542fab823b428712aff083 (patch) | |
tree | c603571ced5da768f906e18f78db282094a2b531 /libpod/container_internal_linux.go | |
parent | c6f2383213b6a8ebf4c4b9f5d5162e7c08fa7c9f (diff) | |
download | podman-368d2ecfb6ee618803542fab823b428712aff083.tar.gz podman-368d2ecfb6ee618803542fab823b428712aff083.tar.bz2 podman-368d2ecfb6ee618803542fab823b428712aff083.zip |
container-restore: Fix restore with user namespace
When restoring a container with user namespace, the user namespace is
created by the OCI runtime, and the network namespace is created after
the user namespace to ensure correct ownership.
In this case PostConfigureNetNS will be set and the value of
c.state.NetNS would be nil. Hence, the following error occurs:
$ sudo podman run --name cr \
--uidmap 0:1000:500 \
-d docker.io/library/alpine \
/bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'
$ sudo podman container checkpoint cr
$ sudo podman container restore cr
...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x13a5e3c]
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 26d6771b0..2ecd5911a 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -884,7 +884,12 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti // We want to have the same network namespace as before. if c.config.CreateNetNS { - if err := g.AddOrReplaceLinuxNamespace(string(spec.NetworkNamespace), c.state.NetNS.Path()); err != nil { + netNSPath := "" + if !c.config.PostConfigureNetNS { + netNSPath = c.state.NetNS.Path() + } + + if err := g.AddOrReplaceLinuxNamespace(string(spec.NetworkNamespace), netNSPath); err != nil { return err } } |