Skip to content
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

fetch_uri: Use memfd for writing #139

Closed
wants to merge 1 commit into from
Closed

fetch_uri: Use memfd for writing #139

wants to merge 1 commit into from

Conversation

ernestask
Copy link
Contributor

Currently, the code uses a GMemoryInputStream for reading the compressed
data that is fetched using libcurl, which does not have seeking
semantics, identical to those of lseek() (i.e. reading past the end
results in a hard error). Seeking is needed to make libarchive use the
seeking decompressor for ZIP archives, because that is the only way it
will read the central directory and get the correct file attributes.

This commit replaces the memory stream with a memfd for reading and a
memfd-backed GUnixOutputStream for writing.

libarchive/libarchive#1106

Fixes #136

Change-Id: Ifdf2e2aef448c9140d9330d6b9a4a754c519df5d

Currently, the code uses a GMemoryInputStream for reading the compressed
data that is fetched using libcurl, which does not have seeking
semantics, identical to those of lseek() (i.e. reading past the end
results in a hard error). Seeking is needed to make libarchive use the
seeking decompressor for ZIP archives, because that is the only way it
will read the central directory and get the correct file attributes.

This commit replaces the memory stream with a memfd for reading and a
memfd-backed GUnixOutputStream for writing.

libarchive/libarchive#1106

Fixes #136

Change-Id: Ifdf2e2aef448c9140d9330d6b9a4a754c519df5d
@ernestask
Copy link
Contributor Author

Well, seems that this will only work on RHEL 8, because the glibc wrapper for memfd_create only exists in glibc 2.27+ and the memfd support is only in Linux 3.17+.

@ernestask
Copy link
Contributor Author

Feel free to reject and steal ideas.

@ernestask ernestask closed this Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task fetch via zip lost perms, this cause Restraint to kill given task
1 participant