mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
libink: trace connections, calls, and authorization decisions
The legacy socket logs a line per command under initctl debug; the bus logged nothing, so the transport that now carries most of initctl was the one you could not watch. libink gets a logger hook rather than a dependency on Finit's: it passes the emitting function and a formatted message, and dbus.c hands both to logit() so the two sources read alike. Trace points cover the connection lifecycle, every inbound call, and why a call was refused. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
63aabaa6df
commit
1e508f9168
9 files changed
+94
-1
No files matched your search
@@ -0,0 +1,40 @@
|
||||
/* libink — optional debug tracing, routed to whoever embeds us.
|
||||
*
|
||||
* libink has no logger of its own by design: it must not depend on the
|
||||
* host's logging, and PID 1 already has one. The embedder installs a
|
||||
* callback and gets a line per connection, call, and authorization
|
||||
* decision. Formatting happens before the callback, so an embedder
|
||||
* that wants tracing off should uninstall rather than filter.
|
||||
*
|
||||
* Copyright (c) 2026 Joachim Wiberg <troglobit@gmail.com>
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
static link_log_cb_t logger;
|
||||
static void *logger_userdata;
|
||||
|
||||
void link_set_logger(link_log_cb_t cb, void *userdata)
|
||||
{
|
||||
logger = cb;
|
||||
logger_userdata = userdata;
|
||||
}
|
||||
|
||||
void __log(const char *func, const char *fmt, ...)
|
||||
{
|
||||
char msg[256];
|
||||
va_list ap;
|
||||
|
||||
if (!logger)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, sizeof(msg), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
logger(logger_userdata, func, msg);
|
||||
}
|
||||
Reference in new issue
Block a user