Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
node/systemd: Check that received sockets are `AF_UNIX`
Merged lorenz opened 8 months ago

Our implementation for the control socket is based on AF_UNIX, and as the note (which is removed suggests, we should actually check that the received socket really is of that domain.

This check was not implemented because it is not exposed via std, and a bit cumbersome to do via libc.

I did not realize that socket2 which neatly sits between std and libc in terms of its abstractions and is cross-platform allows us to do this, and we even already depend on it!

So, add the suggested check.

While at it, refactor the function to return early in cases. Now the progression from a file descriptor to a socket to a listener is nicely captured in the types and not obstructed too much by indentation.

Also log at the error level.

lorenz opened with revision f5ee7dc4 on base 19a262d3 +19 -17 8 months ago

Our implementation for the control socket is based on AF_UNIX, and as the note (which is removed suggests, we should actually check that the received socket really is of that domain.

This check was not implemented because it is not exposed via std, and a bit cumbersome to do via libc.

I did not realize that socket2 which neatly sits between std and libc in terms of its abstractions and is cross-platform allows us to do this, and we even already depend on it!

So, add the suggested check.

While at it, refactor the function to return early in cases. Now the progression from a file descriptor to a socket to a listener is nicely captured in the types and not obstructed too much by indentation.

Also log at the error level.

lorenz pushed revision 2 3567611d on base 19a262d3 +20 -18 8 months ago

Tiny refactor.

lorenz pushed revision 3 af730a95 on base a4d83ec8 +20 -18 8 months ago

Make error messages consistent, rebase.

lorenz pushed revision 4 1276da3b on base a4d83ec8 +21 -18 8 months ago

Add missed return.

fintohaps pushed revision 5 7ce42dc8 on base 8a66e4d0 +0 -0 8 months ago

Rebased

fintohaps merged revision 7ce42dc8 at 8a66e4d0 8 months ago