5

I want to expose methods of my application on System bus using Qt Dbus in Qt Creator. while using session bus ,the methods get exposed, but with system bus I am only able to see the Service name with which i registered but no methods to be exposed under it.(I am checking it in D-feet) What should i do ?

jacknad
  • 13,483
  • 40
  • 124
  • 194
Jenny
  • 71
  • 5
  • I think problem in policy. You add conf file to `/etc/dbus-1/system.d`? I've had same problem, and I solved they by changing config file. – Renat Zaripov Jun 06 '12 at 12:27

1 Answers1

2

You have to place your config file (e.g: example-dbus.conf) in /etc/dbus-1/system.d/

The example-dbus.conf file looks like:

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
  <!-- Only root user can own the service -->
  <policy user="root">
    <allow own="com.company.qtdbus"/>
  </policy>

  <!-- Allow anyone to invoke methods on server, except SetHostName -->
  <policy context="default">
    <allow send_destination="com.company.qtdbus"/>
    <allow receive_sender="com.company.qtdbus"/>

    <deny send_destination="com.company.qtdbus"
          send_interface="com.company.qtdbus.Server" send_member="SetHostName"/>
  </policy>

  <!-- Allow everything, including access to SetHostName -->
  <policy user="root">
    <allow send_destination="com.company.qtdbus"/>
    <allow receive_sender="com.company.qtdbus"/>
  </policy>
</busconfig>

Restart the dbus daemon with /etc/init.d/d-bus restart and now you should be allowed to connect to the system bus. In fact, if you not allowed to connect to the system bus, a error message will be shown.

MeJ
  • 1,088
  • 10
  • 18