test/e2e: fix volumes and suid/dev/exec options

When the source dir is already mounted noexec, nodev or nosuid then a
rootless user cannot mount the dir into the container without these
options for obvious reasons.

So in order to run the test we must ensure the dir is mounted with these
options first, if they are simply skip as the test will fail otherwise.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2024-04-25 17:07:13 +02:00
parent 31034a1b6f
commit 537c21a49a

View File

@ -173,6 +173,20 @@ var _ = Describe("Podman run with volumes", func() {
})
It("podman run with volumes and suid/dev/exec options", func() {
if isRootless() {
// We cannot undo nosuid,nodev,noexec when running rootless for obvious reasons.
// Thus we should check first if our source dir contains such options and skip the test int his case
session := SystemExec("findmnt", []string{"-n", "-o", "OPTIONS", "--target", podmanTest.TempDir})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitCleanly())
output := session.OutputToString()
if strings.Contains(output, "noexec") ||
strings.Contains(output, "nodev") ||
strings.Contains(output, "nosuid") {
Skip("test file system is mounted noexec, nodev or nosuid - cannot bind mount without these options as rootless")
}
}
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
err := os.Mkdir(mountPath, 0755)
Expect(err).ToNot(HaveOccurred())