G_bus_get_sync returns NULL, but dbus_g_bus_get_private works

I am working on old embedded code that uses the legacy dbus-glib library.

In legacy code, this piece of code works well:

GError* error = NULL;
DBusGConnection *systemBus = dbus_g_bus_get_private(DBUS_BUS_SYSTEM, NULL, &error);

Now I tried to get a system bus with the equivalent of GDBus:

GError* error = NULL;
GDBusConnection *systemBus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);

It fails, but error->messagereturns Could not connect: No such file or directory.

Who cares?

By the way, the same call works on the session bus:

GError* error = NULL;
DBusConnection *sessionBus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+4
source share
1 answer

Do you run it with root privileges? In my experience with dbus, access to the system bus is limited. The session bus belongs to the user, so there should never be access problems.

dbus-address-get-for-bus-sync g-dbus-connection-new-for-address, .

0

Source: https://habr.com/ru/post/1628166/


All Articles