From 0faded53b8a8fb65b2c049cf06e743de4e1a3482 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 26 Apr 2024 18:05:31 +0200 Subject: [PATCH] test/e2e: do not leak /tmp/private_file This should use the proper per test tempdir which works just as well for the purpose. Signed-off-by: Paul Holzinger --- test/e2e/build_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 8042dfcb0a..4e52f38fe4 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -441,7 +441,7 @@ RUN find /test`, CITEST_IMAGE) It("podman remote build must not allow symlink for ignore files", func() { // Create a random file where symlink must be resolved // but build should not be able to access it. - privateFile := filepath.Join("/tmp", "private_file") + privateFile := filepath.Join(podmanTest.TempDir, "private_file") f, err := os.Create(privateFile) Expect(err).ToNot(HaveOccurred()) // Mark hello to be ignored in outerfile, but it should not be ignored. @@ -449,16 +449,14 @@ RUN find /test`, CITEST_IMAGE) Expect(err).ToNot(HaveOccurred()) defer f.Close() - // Create .dockerignore which is a symlink to /tmp/private_file. + // Create .dockerignore which is a symlink to /tmp/.../private_file outside of the context dir. currentDir, err := os.Getwd() Expect(err).ToNot(HaveOccurred()) ignoreFile := filepath.Join(currentDir, "build/containerignore-symlink/.dockerignore") err = os.Symlink(privateFile, ignoreFile) Expect(err).ToNot(HaveOccurred()) // Remove created .dockerignore for this test when test ends. - defer func() { - os.Remove(ignoreFile) - }() + defer os.Remove(ignoreFile) if IsRemote() { podmanTest.StopRemoteService()