From: Michael Tremer Date: Mon, 27 Jan 2025 10:37:23 +0000 (+0000) Subject: daemon: Connect to the system dbus X-Git-Tag: 0.9.30~360 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e1cd7252a56c3bce71c44712e01e4c4dc9f0bde;p=pakfire.git daemon: Connect to the system dbus Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/daemon.c b/src/pakfire/daemon.c index 2ba904d4..30106b1a 100644 --- a/src/pakfire/daemon.c +++ b/src/pakfire/daemon.c @@ -25,6 +25,7 @@ #include +#include #include #include @@ -67,6 +68,9 @@ struct pakfire_daemon { // Event Loop sd_event* loop; + // dbus + sd_bus* bus; + // Kerberos Authentication struct { // Context @@ -817,6 +821,19 @@ ERROR: return r; } +static int pakfire_daemon_setup_bus(struct pakfire_daemon* daemon) { + int r; + + // Connect to the system bus + r = sd_bus_open_system(&daemon->bus); + if (r < 0) { + ERROR(daemon->ctx, "Could not connect to system bus: %s\n", strerror(-r)); + return r; + } + + return 0; +} + static int pakfire_daemon_setup_loop(struct pakfire_daemon* daemon) { int r; @@ -950,6 +967,8 @@ static void pakfire_daemon_free(struct pakfire_daemon* daemon) { pakfire_xfer_unref(daemon->control); if (daemon->loop) sd_event_unref(daemon->loop); + if (daemon->bus) + sd_bus_unref(daemon->bus); if (daemon->ctx) pakfire_ctx_unref(daemon->ctx); free(daemon); @@ -980,6 +999,11 @@ int pakfire_daemon_create(struct pakfire_daemon** daemon, struct pakfire_ctx* ct if (r) goto ERROR; + // Setup dbus + r = pakfire_daemon_setup_bus(d); + if (r < 0) + goto ERROR; + // Setup Kerberos Authentication r = pakfire_daemon_setup_krb5(d); if (r)