]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-varlink: unify AF_UNIX check in sd_varlink_set_allow_fd_passing_output()
authorMike Yuan <me@yhndnzj.com>
Mon, 9 Jun 2025 22:01:53 +0000 (00:01 +0200)
committerMike Yuan <me@yhndnzj.com>
Tue, 17 Jun 2025 11:16:43 +0000 (13:16 +0200)
commit72098df8439411b65ddeeddc1e50c8fb3f06be47
tree0f80e4950b7d73ee5ec4be51af3e03a2e5eefcd8
parent60483ea14c585b8f463cf104ac60112acbfb9d45
sd-varlink: unify AF_UNIX check in sd_varlink_set_allow_fd_passing_output()

Currently, the socket type is only checked if the fd passing is
being enabled. The special handling seems unnecessary though,
as in the disable case, either fd passing is already false and
would be caught by the (... == !!b) shortcut at the beginning,
or the AF_UNIX check wouldn't have succeeded in the first place,
for the initial toggle to true. Hence, just uniformly check
AF_UNIX.

While at it, sd_varlink_set_allow_fd_passing_*() oddly return 1
iff changed and !b, which doesn't fit into our coding style and
I can't come up with any use case for such behavior. Let's
return 1 on changed and 0 otherwise.

sd_varlink_set_allow_fd_passing_input() will be fixed in the later
commits with other enhancements.
src/libsystemd/sd-varlink/sd-varlink.c