containers / bubblewrap

Low-level unprivileged sandboxing tool used by Flatpak and similar projects
Other
3.97k stars 237 forks source link

Tidy up handling of intermediate pid fds #665

Open smcv opened 3 weeks ago

smcv commented 3 weeks ago

cc @refi64 @WGH- @mcatanzaro

I think #576 would have better clarity if it was rebased on this and used similar techniques. Reviews welcome, even from non-maintainers.

smcv commented 3 weeks ago

Another unrelated thought: systemd uses a safe_close() wrapper instead of directly close(3) to assert EBADF was not returned, to spot file descriptor mixups,

GLib does similarly, in g_close(). A potential problem with that technique is that the assertion is not going to be async-signal-safe, which is troublesome in a process that forks. On the other hand, bubblewrap is single-threaded, so it's usually OK for us to call non-async-signal-safe functions after fork().