Tidy handling of privileged operation fds #666
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Similar to #665, but for the socket pair that communicates privileged operations between the temporary unprivileged child and the privileged parent when we are setuid root.
Use PIPE_READ_END, PIPE_WRITE_END to clarify use of privileged op sockets
Both sockets in this socket pair are technically bidirectional, but
we're using them in a way that is close enough to unidirectional that
using these symbolic constants is clearer than magic numbers.
We send multi-byte requests into the write end, and read those requests
from the read end (even though we also send a 1-byte reply to each request
into the "read" end, and read it from the "write" end).
utils: Add steal_fd()
This is inspired by g_steal_fd() in GLib, and lets us make it explicit
that ownership of a fd is being moved, similar to steal_pointer().
Clarify ownership of privileged op sockets
Setting the members of privsep_sockets[] to -1 when they have been
closed or had their ownership transferred is clearer than leaving behind
dangling references.
cc @refi64