mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
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>
This commit is contained in:
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user