diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 7150773fe4d5..94fd45f48340 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -33,6 +33,7 @@ import ( . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" "github.com/sirupsen/logrus" + "golang.org/x/sys/unix" ) var ( @@ -983,16 +984,15 @@ func populateCache(podman *PodmanTestIntegration) { // rmAll removes the directory and its content, when running rootless we use // podman unshare to prevent any subuid/gid problems func rmAll(podmanBin string, path string) { - // When using overlay, podman leaves a stray mount behind. This - // leak causes remote tests to take a loooooong time, which then - // causes Cirrus to time out. Unmount the stray. - overlayPath := path + "/root/overlay" - if _, err := os.Stat(overlayPath); err == nil { - umount := exec.Command("umount", overlayPath) - umount.Stdout = GinkgoWriter - umount.Stderr = GinkgoWriter - if err = umount.Run(); err != nil { - GinkgoWriter.Printf("Error umounting %s: %v\n", overlayPath, err) + // When using overlay as root, podman leaves a stray mount behind. This + // leak causes remote tests to take a loooooong time, which then causes + // Cirrus to time out. Unmount the stray. + if os.Geteuid() == 0 { + overlayPath := path + "/root/overlay" + if _, err := os.Stat(overlayPath); err == nil { + if err = unix.Unmount(overlayPath, unix.MNT_DETACH); err != nil { + GinkgoWriter.Printf("Error unmounting %s: %v\n", overlayPath, err) + } } }