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

Replace flatpak_close_fds_workaround() with g_fdwalk_set_cloexec() #5687

Merged
merged 2 commits into from Feb 15, 2024

Conversation

smcv
Copy link
Collaborator

@smcv smcv commented Feb 13, 2024

  • build: Consistently put libglnx.la last in lists of dependencies

    It needs to be able to satisfy dependencies of higher-level Flatpak
    static libraries.

  • Replace flatpak_close_fds_workaround() with g_fdwalk_set_cloexec()

    flatpak_close_fds_workaround() wasn't technically async-signal-safe,
    because the requirement for sysconf() to be async-signal-safe was
    removed in POSIX.1-2008.

    It could also leave high fds open in some cases: in practice
    sysconf(_SC_OPEN_MAX) returns the soft resource limit, but if our
    resource limit has been reduced by an ancestor process, we could
    conceivably still have fds open and inherited above that number.

    We can fix this by using g_fdwalk_set_cloexec() with GLib >= 2.79.2,
    or the backport in libglnx with older GLib. This uses close_range()
    if possible, falling back to rummaging in /proc with async-signal-safe
    syscalls.

It needs to be able to satisfy dependencies of higher-level Flatpak
static libraries.

Signed-off-by: Simon McVittie <smcv@collabora.com>
flatpak_close_fds_workaround() wasn't technically async-signal-safe,
because the requirement for sysconf() to be async-signal-safe was
removed in POSIX.1-2008.

It could also leave high fds open in some cases: in practice
sysconf(_SC_OPEN_MAX) returns the soft resource limit, but if our
resource limit has been reduced by an ancestor process, we could
conceivably still have fds open and inherited above that number.

We can fix this by using g_fdwalk_set_cloexec() with GLib >= 2.79.2,
or the backport in libglnx with older GLib. This uses close_range()
if possible, falling back to rummaging in /proc with async-signal-safe
syscalls.

Signed-off-by: Simon McVittie <smcv@collabora.com>
@smcv smcv merged commit 7b1cd20 into flatpak:main Feb 15, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants