mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 00:15:44 +00:00
[v5.6-rhel] libpod: fix workdir MkdirAll() all check
MkdirAll can fail with EEXIST when the path is a symlink and the target doesn't exist. As such we should ignore the error. Note there is something fundemantal wrong here with the path access as it is following the symlink to the host, however it is only for a stat() so it is not an security issue here. Fixes:637c264e2e("fix issues found by nilness") Signed-off-by: Paul Holzinger <pholzing@redhat.com> (cherry picked from commit7b1be7f177) Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
This commit is contained in:
parent
360c775708
commit
bd01c413cf
2 changed files with 14 additions and 1 deletions
|
|
@ -932,7 +932,10 @@ func (c *Container) resolveWorkDir() error {
|
|||
// we need to return the full error.
|
||||
return fmt.Errorf("detecting workdir %q on container %s: %w", workdir, c.ID(), err)
|
||||
}
|
||||
if err := os.MkdirAll(resolvedWorkdir, 0755); err != nil {
|
||||
if err := os.MkdirAll(resolvedWorkdir, 0o755); err != nil {
|
||||
if errors.Is(err, fs.ErrExist) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("creating container %s workdir: %w", c.ID(), err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,4 +57,14 @@ WORKDIR /etc/foobar`, ALPINE)
|
|||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToString()).To(Equal("/home/foobar"))
|
||||
})
|
||||
|
||||
It("podman run on an image with a symlinked workdir", func() {
|
||||
dockerfile := fmt.Sprintf(`FROM %s
|
||||
RUN mkdir /A && ln -s /A /B
|
||||
WORKDIR /B`, ALPINE)
|
||||
podmanTest.BuildImage(dockerfile, "test", "false")
|
||||
|
||||
session := podmanTest.PodmanExitCleanly("run", "test", "pwd")
|
||||
Expect(session.OutputToString()).To(Equal("/A"))
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue