From de75b1a2778fa08d50ecf573b3259b32b68912d7 Mon Sep 17 00:00:00 2001 From: Matthew Heon <matthew.heon@pm.me> Date: Sun, 23 Jun 2019 17:03:06 -0400 Subject: [PATCH] Fix a segfault in 'podman ps --sync' We weren't properly populating the container's OCI Runtime in Batch(), causing segfaults on attempting to access it. Add a test to make sure we actually catch cases like this in the future. Fixes #3411 Signed-off-by: Matthew Heon <matthew.heon@pm.me> --- libpod/container_api.go | 1 + test/e2e/ps_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/libpod/container_api.go b/libpod/container_api.go index ed3e08dc7a..370e3e5d9b 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -627,6 +627,7 @@ func (c *Container) Batch(batchFunc func(*Container) error) error { newCtr.config = c.config newCtr.state = c.state newCtr.runtime = c.runtime + newCtr.ociRuntime = c.ociRuntime newCtr.lock = c.lock newCtr.valid = true diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index b0a28501a0..2b86f663fb 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -320,4 +320,16 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:1000-1006")) }) + + It("podman ps sync flag", func() { + session := podmanTest.RunTopContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--sync"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToStringArray()[0]).To(Equal(fullCid)) + }) })