libink: a broker peer is not an ordinary client

libink was written peer to peer, where one connection is one client
and one principal.  Attaching to a message bus breaks both halves of
that, and two things followed from it.

Signals never reached the system bus.  Fan-out is gated on the peer
having sent AddMatch, but a broker subscribes for its own clients and
never sends us one, so every ServiceStateChanged was dropped on the
floor.  A connection attached with LINK_ATTACH_BROKER gets them all.

Hello, AddMatch and RemoveMatch write per-connection state.  Shared by
every caller behind a broker, that lets one sender exhaust the match
cap or drop another's rule, so we leave all three to the bus, whose
job they are.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-08-13 10:14:48 +02:00
1 parent abab0e0fd4
commit c71ccce742
6 files changed
+38 -9

No files matched your search

+10 -2
View File
@@ -105,8 +105,16 @@ int link_server_accept(link_server_t *server, link_connection_t **conn);
*
* On success the connection takes ownership of `fd`. On any failure
* `fd` is closed before the function returns NULL, so callers never
* have to track partial state. */
link_connection_t *link_server_attach(link_server_t *server, int fd, uid_t peer_uid);
* have to track partial state.
*
* LINK_ATTACH_BROKER says the peer is a message bus rather than an
* ordinary client. A broker subscribes on behalf of its own clients
* and never sends us AddMatch, so signals go to it unconditionally
* instead of being filtered by this connection's match rules. */
#define LINK_ATTACH_BROKER 0x01
link_connection_t *link_server_attach(link_server_t *server, int fd, uid_t peer_uid,
unsigned int attach_flags);
int link_connection_get_fd (const link_connection_t *conn);
uid_t link_connection_get_uid (const link_connection_t *conn);