From 0bd0ad59436436e93ac81ce46059d8618ed7766c Mon Sep 17 00:00:00 2001 From: Aditya R Date: Wed, 2 Mar 2022 15:07:06 +0530 Subject: container: workdir resolution must consider symlink if explicitly configured 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 --- test/e2e/build/workdir-symlink/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/e2e/build/workdir-symlink/Dockerfile (limited to 'test/e2e/build') diff --git a/test/e2e/build/workdir-symlink/Dockerfile b/test/e2e/build/workdir-symlink/Dockerfile new file mode 100644 index 000000000..abc9b47ee --- /dev/null +++ b/test/e2e/build/workdir-symlink/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine +RUN mkdir /tmp/destination +RUN ln -s /tmp/destination /tmp/link +WORKDIR /tmp/link +CMD ["echo", "hello"] -- cgit v1.2.3-54-g00ecf