-
Notifications
You must be signed in to change notification settings - Fork 111
Fix SquashFS extraction when it contains directory symlinks #3105
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
Conversation
A SquashFS image might contain directory symlinks such as `/var/tmp -> /tmp`. Before extraction a base environment is created (`makeBaseEnv`) by pre-creating some directories. Among them `/var/tmp`. Although unsquashfs is called with `-force` it fails to replace that by the symlink in the image as it removes only directories. Introduce a pre-extraction step listing the contents of the image and searching for all entries which are existing directories. Remove those to avoid the issue. Fixes sylabs#3084
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.
Hi @Flamefire - thanks for sharing this. However, it's not the approach we want to take.
- Relying on scanning the output of
unsquashfsis brittle to any changes in that tool, and adds significant complexity to that code. (edit... we are now using squashfs-tools-ng tools elsewhere, and may want to here at some point, so this is why parsing unsquashfs output is additionally an issue) - In other code paths, where we build e.g. from an OCI source, rather than a local image file, the directories are created after image extraction, which avoids this issue. We believe we can swap the order of operations for the localimage conveyorpacker code to fix it in a much simpler manner.
I've been discussing this with @cyanezstange and he will be tackling the issue in the next week.
Create a folder to be packed into an image with the following layout:
/tmp
/var
/tmp -> ../tmp
Unpack that to a folder containing the directory /var/tmp
Check that this was replaced by the symlink and other files are
extracted normally
7ebfd9a to
491708f
Compare
I made it as simple as possible with as few assumptions as possible. E.g. using So the only assumption I did was that the output of
You are right, that is likely better |
Create a squashf image unpacked with the following layout:
/tmp
/var
/tmp -> ../tmp
Check that this yields the symlink and other files are extracted normally
A SquashFS image might contain directory symlinks such as `/var/tmp -> /tmp`. Before extraction a base environment is created (`makeBaseEnv`) by pre-creating some directories. Among them `/var/tmp`. Although unsquashfs is called with `-force` it fails to replace that by the symlink in the image as it removes only directories. Fix by creating the base env after the extracion as done for e.g. OCI images. Fixes sylabs#3084
eed8c42 to
12b56ae
Compare
|
Hi @Flamefire , thank you for this PR. I have tidy some thing in #3151 which keep you as an contributor. Please let us know if you don't want to be listed in the CONTRIBUTORS.md file or have any others concerns. |
|
That's fine for me, thanks! |
Description of the Pull Request (PR):
A SquashFS image might contain directory symlinks such as
/var/tmp -> /tmp. Before extraction a base environment is created (makeBaseEnv) by pre-creating some directories. Among them/var/tmp. Although unsquashfs is called with-forceit fails to replace that by the symlink in the image as it removes only directories.As per suggestion from @dtrudg the base environment causing the trouble is created after the extraction as done for e.g. OCI images.
This fixes or addresses the following GitHub issues: