Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introspection doesn't work for paths below the one passed to conn.Export #14

Open
krnowak opened this issue Jan 28, 2015 · 1 comment
Open

Comments

@krnowak
Copy link

krnowak commented Jan 28, 2015

See the terminal session below for ca.desrt.dconf service using GLib's GDBus:

[krnowak@localhost _examples]$ dbus-send --dest='ca.desrt.dconf' --type=method_call \
--print-reply / org.freedesktop.DBus.Introspectable.Introspect
method return sender=:1.74 -> dest=:1.141 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- GDBus 2.42.1 -->
<node>
  <node name="ca"/>
</node>
"
[krnowak@localhost _examples]$ dbus-send --dest='ca.desrt.dconf' --type=method_call \
--print-reply /ca org.freedesktop.DBus.Introspectable.Introspect
method return sender=:1.74 -> dest=:1.142 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- GDBus 2.42.1 -->
<node>
  <node name="desrt"/>
</node>
"
[krnowak@localhost _examples]$ dbus-send --dest='ca.desrt.dconf' --type=method_call \
--print-reply /ca/desrt org.freedesktop.DBus.Introspectable.Introspect
method return sender=:1.74 -> dest=:1.143 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- GDBus 2.42.1 -->
<node>
  <node name="dconf"/>
</node>
"
[krnowak@localhost _examples]$ dbus-send --dest='ca.desrt.dconf' --type=method_call \
--print-reply /ca/desrt/dconf org.freedesktop.DBus.Introspectable.Introspect
method return sender=:1.74 -> dest=:1.147 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- GDBus 2.42.1 -->
<node>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg type="s" name="interface_name" direction="in"/>
      <arg type="s" name="property_name" direction="in"/>
      <arg type="v" name="value" direction="out"/>
    </method>
    ...
    <signal name="PropertiesChanged">
      <arg type="s" name="interface_name"/>
      <arg type="a{sv}" name="changed_properties"/>
      <arg type="as" name="invalidated_properties"/>
    </signal>
  </interface>
  <interface name="org.freedesktop.DBus.Introspectable">
    ...
  </interface>
  ...
  <node name="shm"/>
  <node name="Writer"/>
  <node name="keyfile"/>
</node>
"

In short - calling Introspect on / (root) returns information that this node has one child node - ca. Then doing the same for /ca yields in child node desrt. For /ca/desrt -> dconf. And finally for /ca/desrt/dconf we are getting a bunch of interfaces. And more child nodes to introspect.

Now, terminal session for server example:

[krnowak@localhost _examples]$ dbus-send --dest='com.github.guelfey.Demo' \
--type=method_call --print-reply / org.freedesktop.DBus.Introspectable.Introspect
Error org.freedesktop.DBus.Error.NoSuchObject: No such object
[krnowak@localhost _examples]$ dbus-send --dest='com.github.guelfey.Demo' \
--type=method_call --print-reply /com org.freedesktop.DBus.Introspectable.Introspect
Error org.freedesktop.DBus.Error.NoSuchObject: No such object
[krnowak@localhost _examples]$ dbus-send --dest='com.github.guelfey.Demo' \
--type=method_call --print-reply /com/github org.freedesktop.DBus.Introspectable.Introspect
Error org.freedesktop.DBus.Error.NoSuchObject: No such object
[krnowak@localhost _examples]$ dbus-send --dest='com.github.guelfey.Demo' \
--type=method_call --print-reply /com/github/guelfey \
org.freedesktop.DBus.Introspectable.Introspect
Error org.freedesktop.DBus.Error.NoSuchObject: No such object
[krnowak@localhost _examples]$ dbus-send --dest='com.github.guelfey.Demo' \
--type=method_call --print-reply /com/github/guelfey/Demo \
org.freedesktop.DBus.Introspectable.Introspect 
method return sender=:1.96 -> dest=:1.152 reply_serial=2
   string "
<node>
    <interface name="com.github.guelfey.Demo">
        <method name="Foo">
            <arg direction="out" type="s"/>
        </method>
    </interface>
    <interface name="org.freedesktop.DBus.Introspectable">
        <method name="Introspect">
            <arg name="out" direction="out" type="s"/>
        </method>
    </interface>
</node> "

That means that services written with go-dbus are not introspectable by d-feet for example.

@demon-xxi
Copy link

This seems like an extra logic needs to be added to https://github.com/godbus/dbus/blob/master/export.go#L48 when no object is found for the path.
Get all the objects child to the specified path.

But to make it fully complaint the introspection of any existing object has to return nodes for child exposed objects. So this method would need to detect introspection call, then if object is found get its introspection data, then add any existing child objects path names and then return combined result.

for child names it is usually enough to return part of the path to the first /.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants