diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index 4c701eedb9..1dfce61041 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -120,7 +120,7 @@ func generateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) []ignition mountUnit.Add("Mount", "What", "%s") mountUnit.Add("Mount", "Where", "%s") mountUnit.Add("Mount", "Type", "virtiofs") - mountUnit.Add("Mount", "Options", "defcontext=\"system_u:object_r:nfs_t:s0\"") + mountUnit.Add("Mount", "Options", "context=\"system_u:object_r:nfs_t:s0\"") mountUnit.Add("Install", "WantedBy", "multi-user.target") mountUnitFile, err := mountUnit.ToString() if err != nil { diff --git a/pkg/machine/e2e/basic_test.go b/pkg/machine/e2e/basic_test.go index 3429f78e41..f1826a403b 100644 --- a/pkg/machine/e2e/basic_test.go +++ b/pkg/machine/e2e/basic_test.go @@ -11,6 +11,7 @@ import ( "path/filepath" "time" + "github.com/containers/podman/v5/pkg/machine/define" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" @@ -69,6 +70,37 @@ var _ = Describe("run basic podman commands", func() { Expect(rmCon).To(Exit(0)) }) + It("Volume ops", func() { + skipIfVmtype(define.HyperVVirt, "FIXME: #21036 - Hyper-V podman run -v fails due to path translation issues") + + tDir, err := filepath.Abs(GinkgoT().TempDir()) + Expect(err).ToNot(HaveOccurred()) + roFile := filepath.Join(tDir, "attr-test-file") + + // Create the file as ready-only, since some platforms disallow selinux attr writes + // The subsequent Z mount should still succeed in spite of that + rf, err := os.OpenFile(roFile, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0o444) + Expect(err).ToNot(HaveOccurred()) + rf.Close() + + name := randomString() + i := new(initMachine).withImage(mb.imagePath).withNow() + + // All other platforms have an implicit mount for the temp area + if isVmtype(define.QemuVirt) { + i.withVolume(tDir) + } + session, err := mb.setName(name).setCmd(i).run() + Expect(err).ToNot(HaveOccurred()) + Expect(session).To(Exit(0)) + + bm := basicMachine{} + // Test relabel works on all platforms + runAlp, err := mb.setCmd(bm.withPodmanCommand([]string{"run", "-v", tDir + ":/test:Z", "quay.io/libpod/alpine_nginx", "ls", "/test/attr-test-file"})).run() + Expect(err).ToNot(HaveOccurred()) + Expect(runAlp).To(Exit(0)) + }) + It("Podman ops with port forwarding and gvproxy", func() { name := randomString() i := new(initMachine)