Skip to content

Commit

Permalink
asio: object_server: remove invalid root interface
Browse files Browse the repository at this point in the history
Right now a trivial snippet of code will throw an exception:
```
    boost::asio::io_service io;
    auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);

    systemBus->request_name(this_name);
    sdbusplus::asio::object_server objectServer(systemBus);
```

In commit 017a19d, code was added to detect the return code from
`sd_bus_add_object_vtable` and turn it into an exception.  It turns out
that our existing `asio::object_server` is triggering this exception
itself.

I traced the issue down to the empty-named interface being added into
the / path by `asio::object_server`:
```
    auto root = add_interface("/", "");
```

Empty interface names are invalid and thus this gives us an error from
`sd_bus_add_object_vtable`.  I cannot tell the history or rationale on
this code, because it has been around from the beginning, but I suspect
at one point if we didn't have _some_ object we also did not get an
`ObjectManager` interface.  I deleted this code now and confirmed we do
still get an `ObjectManager`.

```
$ busctl --user tree xyz.openbmc_project.sdbusplus.test.Aio
Only root object discovered.
$ busctl --user introspect xyz.openbmc_project.sdbusplus.test.Aio / |
    grep interface
org.freedesktop.DBus.Introspectable interface -          -             -
org.freedesktop.DBus.ObjectManager  interface -          -             -
org.freedesktop.DBus.Peer           interface -          -             -
org.freedesktop.DBus.Properties     interface -          -             -
```

Since we still get an `ObjectManager` and this code likely hasn't worked
for quite a while, but was silently ignoring the error from sd-bus, I
think we are safe to remove it.

Reported-by: Andrew Geissler <geissonator@yahoo.com>
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I989ae218a882bc2e45594cb380d318e6a8f0f17e
  • Loading branch information
williamspatrick committed Jun 9, 2020
1 parent bb140d1 commit fb0366b
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions include/sdbusplus/asio/object_server.hpp
Expand Up @@ -799,8 +799,6 @@ class object_server
{
if (!skipManager)
{
auto root = add_interface("/", "");
root->initialize();
add_manager("/");
}
}
Expand Down

0 comments on commit fb0366b

Please sign in to comment.