diff options
author | Slava Bacherikov <slava@bacher09.org> | 2021-05-06 00:43:02 +0300 |
---|---|---|
committer | Slava Bacherikov <slava@bacher09.org> | 2021-05-06 19:24:14 +0300 |
commit | d6fd5289008c595c0aa49e9f9d06632795adca82 (patch) | |
tree | 66f53767d47f15d4d6d9589140362263491c5dbb | |
parent | ed6f399770946bb2e88f8b94e1d2f279208648d4 (diff) | |
download | podman-d6fd5289008c595c0aa49e9f9d06632795adca82.tar.gz podman-d6fd5289008c595c0aa49e9f9d06632795adca82.tar.bz2 podman-d6fd5289008c595c0aa49e9f9d06632795adca82.zip |
Fix infinite loop in isPathOnVolume
filepath.Dir in some cases returns `.` symbol and calling this function
again returns same result. In such cases this function
never returns and causes some operations to stuck forever.
Closes #10216
Signed-off-by: Slava Bacherikov <slava@bacher09.org>
-rw-r--r-- | libpod/container_path_resolution.go | 2 | ||||
-rw-r--r-- | test/e2e/run_test.go | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libpod/container_path_resolution.go b/libpod/container_path_resolution.go index d798963b1..ec7306ca1 100644 --- a/libpod/container_path_resolution.go +++ b/libpod/container_path_resolution.go @@ -128,7 +128,7 @@ func isPathOnVolume(c *Container, containerPath string) bool { if cleanedContainerPath == filepath.Clean(vol.Dest) { return true } - for dest := vol.Dest; dest != "/"; dest = filepath.Dir(dest) { + for dest := vol.Dest; dest != "/" && dest != "."; dest = filepath.Dir(dest) { if cleanedContainerPath == dest { return true } diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index d8d7dab07..9976e743a 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -921,6 +921,17 @@ USER mail`, BB) Expect(session.OutputToString()).To(ContainSubstring("mail root")) }) + It("podman run with incorect VOLUME", func() { + dockerfile := fmt.Sprintf(`FROM %s +VOLUME ['/etc/foo'] +WORKDIR /etc/foo`, BB) + podmanTest.BuildImage(dockerfile, "test", "false") + session := podmanTest.Podman([]string{"run", "--rm", "test", "echo", "test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("test")) + }) + It("podman run --volumes-from flag", func() { vol := filepath.Join(podmanTest.TempDir, "vol-test") err := os.MkdirAll(vol, 0755) |