Skip to content

Commit

Permalink
test: fix rootless propagation test
Browse files Browse the repository at this point in the history
the test works only when the user owns the outer mount namespace,
which is likely not the case when running in rootless mode.

Closes: #20076

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Sep 21, 2023
1 parent e209c40 commit 83b6975
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 83b6975

Please sign in to comment.