gdbus ObjectManager confusion with Peer/Introspectable/Properties/ObjectManager interfaces (sd-bus)
Submitted by David Härdeman
Link to original bug (#781524)
Description
I'm currently trying to write a server using sd-bus (from systemd) and a client using gdbus and I've come across something I believe is a bug in gdbus.
I've implemented an ObjectManager server living at org.gnome.TestManager with the path /org/gnome/TestManager which exports objects under /org/gnome/TestManager/fooX with interface org.gnome.TestManager.Device.
sd-bus appears to interpret the ObjectManager API differently from gdbus, when an object is removed, an sd-bus based ObjectManager server sends the following signal:
signal time=1492642227.714223 sender=:1.104 -> destination=(null destination) serial=90 path=/org/gnome/TestManager; interface=org.freedesktop.DBus.ObjectMana object path "/org/gnome/TestManager/foo0" array [ string "org.freedesktop.DBus.Peer" string "org.freedesktop.DBus.Introspectable" string "org.freedesktop.DBus.Properties" string "org.freedesktop.DBus.ObjectManager" string "org.gnome.TestManager.Device" ]
While a gdbus ObjectManager server sends:
signal time=1492642227.714223 sender=:1.104 -> destination=(null destination) serial=90 path=/org/gnome/TestManager; interface=org.freedesktop.DBus.ObjectMana object path "/org/gnome/TestManager/foo0" array [ string "org.gnome.TestManager.Device" ]
I've already reported the difference in number of interfaces to the systemd mailing list. However, the difference also seems to expose a bug in gdbus.
If the sd-bus based server is already running and exposing an object (/org/gnome/TestManager/foo0) when I start the client, the client will report that the object has a single interface (org.gnome.TestManager.Device). If an object is added while the client is running, it will report the object as having five interfaces (and for the org.freedesktop.DBus.* interfaces, g_dbus_interface_get_info() will return NULL).
This means that when an object which existed at client startup is removed, gdbus will not trigger the "object-removed" signal because there is a mismatch in the interface count. This is checked in ./gio/gdbusobjectmanagerclient.c:remove_interfaces(), see the comparison of num_interfaces_to_remove == num_interfaces.
Now, the additional interfaces may be an sd-bus bug, but there also seems to be a bug in gdbus given the confusion over how many interfaces such an object is reported as having.
(Tested using the version of glib2.0 in Debian unstable, currently 2.50.0)
Version: 2.50.x