-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
container: workdir resolution must consider symlink
if explicitly configured
#13399
container: workdir resolution must consider symlink
if explicitly configured
#13399
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cc10e2a
to
841dbf3
Compare
Failing reproducer without this PR would be FROM alpine
RUN mkdir /tmp/destination
RUN ln -s /tmp/destination /tmp/link
WORKDIR /tmp/link
CMD ["echo", "hello"] $ podman build -t test .
$ podman run --workdir /tmp/link test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some inline comments.
Please also fix the commit message, the first line is too long
841dbf3
to
dc26ed7
Compare
symlink
if explicitly configured using --workdir
or implicity using others e.g podman play kube
symlink
if explicitly configured using --workdir
symlink
if explicitly configured using --workdir
symlink
if explicitly configured
dc26ed7
to
ffad3fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the target is another symlink?
There is some duplication here we could probably avoid. What do you think about keep calling c.resolvePath()
until the result is not a symlink (up to a limit to avoid loops)?
ffad3fc
to
58dbb61
Compare
@giuseppe This is a valid concern, I have addressed this in new commit and can be verified with FROM alpine
RUN mkdir /tmp/destination
RUN ln -s /tmp/destination /tmp/link
RUN ln -s /tmp/link /tmp/link2
RUN ln -s /tmp/link2 /tmp/link3
WORKDIR /tmp/link3
CMD ["echo", "hello"] $ podman run --workdir /tmp/link3 test |
8a9a7d2
to
569256e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit, could we have this functionality in a separate function?
Beside that, LGTM
569256e
to
93a3888
Compare
…figured While resolving `workdir` we mostly create a `workdir` when `stat` fails with `ENOENT` or `ErrNotExist` however following cases are not true when user explicitly specifies a `workdir` while `running` using `--workdir` which tells `podman` to only use workdir if its exists on the container. Following configuration is implicity set with other `run` mechanism like `podman play kube` Problem with explicit `--workdir` or similar implicit config in `podman play kube` is that currently podman ignores the fact that workdir can also be a `symlink` and actual `link` could be valid. Hence following commit ensures that in such scenarios when a `workdir` is not found and we cannot create a `workdir` podman must perform a check to ensure that if `workdir` is a `symlink` and `link` is resolved successfully and resolved link is present on the container then we return as it is. Docker performs a similar behviour. Signed-off-by: Aditya R <[email protected]>
93a3888
to
0bd0ad5
Compare
/lgtm |
While resolving workdir we mostly create a workdir when
stat
fails with
ENOENT
orErrNotExist
however following cases are nottrue when user explicitly specifies a workdir while
running
using--workdir
which tells podman to only use workdir if its exists onthe container. Following configuration is implicity set with other
run
mechanism likepodman play kube
Problem with explicit
--workdir
or similar implicit config inpodman play kube
is that currently podman ignores the fact that workdir can also bea
symlink
and actuallink
could be valid.Hence following commit ensures that in such scenarios when a workdir
is not found and we cannot create a workdir podman must perform a
check to ensure that if workdir is a
symlink
andlink
is resolvedsuccessfully and resolved link is present on the container then we
return as it is.
Docker performs a similar behavior.
Closes: #13346