chiark / gitweb /
bus: never respond to GetManagedObjects() on sub-paths
authorDavid Herrmann <dh.herrmann@gmail.com>
Wed, 17 Sep 2014 07:28:09 +0000 (09:28 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Wed, 17 Sep 2014 09:01:52 +0000 (11:01 +0200)
commit943c3f94e2f8b8b35ef6a40220bbe4c06510930c
treec7829cb8ac7489c73c811eb5d035fc447496a56f
parent0e1f579227b08832437a7ac2227c7e4007a89d23
bus: never respond to GetManagedObjects() on sub-paths

The dbus-spec clearly specifies that GetManagedObjects() should only work
on the root-path of an object-tree. But on that path, it works regardless
whether there are any objects available or not.

We could, technically, define all sub-paths as a root-path of its own
sub-tree. However, if we do that, we enter undefined territory:

    Imagine only a fallback vtable is registered. We want
    GetManagedObjects() to *NOT* fail with UNKNOWN_METHOD if it is called
    on a valid sub-tree of the fallback. On the other hand, we don't want
    it to work on arbitrary sub-tree. Something like:
        /path/to/fallback/foobar/foobar/foobar/invalid/foobar
    should not work.
    However, there is no way to know which paths on a fallback are valid
    without looking at there registered objects. If no objects are
    registered, we have no way to figure it out.

Therefore, we now try to follow the dbus spec by only returning valid data
on registered root-paths. We treat each path as root which was registered
an object-manager on via add_object_manager(). So applications can now
directly control which paths to place an object-manager on.

We also fix the introspection to not return object-manager interfaces on
non-root paths.

Also fixes some dead-code paths initially reported by Philippe De Swert.
src/libsystemd/sd-bus/bus-objects.c