Relative symlinks not working in some cases
Context
This issue is about handling relative symlinks in CAS downloader.
Currently relative symlink's target path is resolved into an absolute path. For example, with following nodes:
<root>
│ file1
└── folder1
└── symlink1 --> ../file1
being downloaded to /tmp/host
the symlink1
's symlink target will be resolved to /tmp/host/file1
.
This is fine as long as host tools worker is used and the command is being run directly from the worker filesystem. Things get tricky if the command requested to be run is wrapped in script that makes it run inside a docker container with /tmp/host
root path being mounted as a docker volume. For example - lets consider following command to be requested to be executed on the worker:
docker run ---volume $(pwd):/inner --workdir /inner <some_image> cat ./folder1/symlink
The cat
command is going top be run from within /inner
folder. The symlink exists but it points to /tmp/host/file1
which is invalid path within the docker container.
There is another issue directly related to this code - if the target path crosses root_barrier
the link creation will be silently skipped while IMO is should raise an exception here to signal something is wrong with the request that came from client.
Task Description
I may be missing some background but I think is should be possible to use relative paths for link targets as long as the relative symlink path does not cross the root_barrier
.
Attaching the solution that seems to work for me. In short: it still checks the root_barrier
boundary but does not resolve relative links. In addition it raises an exception when the link crosses root_barrier
and is considered invalid.
Patch: diff.patch