From 22b0bb21383614f6258dee27f4a254d2da97b586 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Wed, 17 Jun 2020 19:08:14 -0700 Subject: Add TempTmpMount test This currently doesn't work with VSF2. Add test to ensure it's not missed. Updates #1487 PiperOrigin-RevId: 317013792 --- test/e2e/integration_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/e2e/integration_test.go b/test/e2e/integration_test.go index 91c956e10..60e739c6a 100644 --- a/test/e2e/integration_test.go +++ b/test/e2e/integration_test.go @@ -24,10 +24,12 @@ package integration import ( "flag" "fmt" + "io/ioutil" "net" "net/http" "os" "os/exec" + "path/filepath" "strconv" "strings" "syscall" @@ -389,6 +391,37 @@ func TestTmpFile(t *testing.T) { } } +// TestTmpMount checks that mounts inside '/tmp' are not overridden. +func TestTmpMount(t *testing.T) { + dir, err := ioutil.TempDir(testutil.TmpDir(), "tmp-mount") + if err != nil { + t.Fatalf("TempDir(): %v", err) + } + want := "123" + if err := ioutil.WriteFile(filepath.Join(dir, "file.txt"), []byte("123"), 0666); err != nil { + t.Fatalf("WriteFile(): %v", err) + } + d := dockerutil.MakeDocker(t) + defer d.CleanUp() + + opts := dockerutil.RunOpts{ + Image: "basic/alpine", + Mounts: []dockerutil.Mount{ + { + Source: dir, + Target: "/tmp/foo", + }, + }, + } + got, err := d.Run(opts, "cat", "/tmp/foo/file.txt") + if err != nil { + t.Fatalf("docker run failed: %v", err) + } + if want != got { + t.Errorf("invalid file content, want: %q, got: %q", want, got) + } +} + // TestHostOverlayfsCopyUp tests that the --overlayfs-stale-read option causes // runsc to hide the incoherence of FDs opened before and after overlayfs // copy-up on the host. -- cgit v1.2.3