From 83b6975d1095a61d658c131a64140e558ddef394 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 21 Sep 2023 12:31:18 +0200 Subject: [PATCH] test: fix rootless propagation test the test works only when the user owns the outer mount namespace, which is likely not the case when running in rootless mode. Closes: https://github.com/containers/podman/issues/20076 Signed-off-by: Giuseppe Scrivano --- test/e2e/run_test.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index ae8db35d9a..4f66cfd4c8 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -1259,19 +1259,26 @@ VOLUME %s`, ALPINE, volPath, volPath) }) It("podman run findmnt shared", func() { - vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") - err := os.MkdirAll(vol1, 0755) - Expect(err).ToNot(HaveOccurred()) - vol2 := filepath.Join(podmanTest.TempDir, "vol-test2") - err = os.MkdirAll(vol2, 0755) + vol := filepath.Join(podmanTest.TempDir, "vol-test") + err := os.MkdirAll(vol, 0755) Expect(err).ToNot(HaveOccurred()) - session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:shared,z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"}) + session := podmanTest.Podman([]string{"run", "--volume", vol + ":/myvol:z", fedoraMinimal, "findmnt", "-no", "PROPAGATION", "/myvol"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.OutputToString()).To(ContainSubstring("shared")) - // make sure it's only shared (and not 'shared,slave') - Expect(session.OutputToString()).To(Not(ContainSubstring("shared,"))) + Expect(session.OutputToString()).To(Equal("private")) + + session = podmanTest.Podman([]string{"run", "--volume", vol + ":/myvol:shared,z", fedoraMinimal, "findmnt", "-no", "PROPAGATION", "/myvol"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + if isRootless() { + // we need to relax the rootless test because it can be "shared" only when the user owns the outer mount namespace. + Expect(session.OutputToString()).To(ContainSubstring("shared")) + } else { + // make sure it's only shared (and not 'shared,*') + Expect(session.OutputToString()).To(Equal("shared")) + } }) It("podman run --security-opts proc-opts=", func() {