ingester
ingester
¶
Unix-socket ingester that relays container events onto the session bus.
Per-container NFLOG readers live in NS_ROOTLESS (the rootless-podman
user namespace that owns the container netns). From there, the session
dbus-daemon's SO_PEERCRED check rejects their connection attempts
— even when DBUS_SESSION_BUS_ADDRESS points at the right socket.
The hub runs in the host user namespace, so it can reach the session
bus. EventIngester gives the readers a pipe to cross: it owns
a unix socket that accepts line-delimited JSON events from any local
connection, decodes them, and calls the matching ShieldHub
signal methods on the bus — where emission works.
One socket per hub, one hub per user session. Readers reconnect on their own if the hub restarts; the hub tolerates disconnected readers without logging.
EventIngester(*, socket_path, on_event)
¶
Accepts JSON event lines from container readers and forwards to the hub.
Keeps ownership of one AF_UNIX listener and a set of accepted-connection handler tasks. Socket file mode is 0600: only the hub's running user can read or write to it, matching the session bus's own ACL model.
Bind the ingester to a filesystem path and a sink coroutine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
socket_path
|
Path
|
Where the listening AF_UNIX socket will live. The path is unlinked first if a stale file exists, so a crashed previous run doesn't deadlock startup. |
required |
on_event
|
Callable[[dict], Awaitable[None]]
|
Coroutine the ingester awaits once per parsed event. Expected to emit the corresponding D-Bus signal; exceptions raised here are logged and swallowed so one bad event can't tear down the ingester. |
required |
Source code in src/terok_clearance/hub/ingester.py
start()
async
¶
Bind the socket and start accepting connections in the background.
Source code in src/terok_clearance/hub/ingester.py
stop()
async
¶
Close the server and await any in-flight client tasks.
Source code in src/terok_clearance/hub/ingester.py
default_socket_path()
¶
Return the canonical ingester path under $XDG_RUNTIME_DIR.