how can I add a SystemBus for example-services.py

Qin Bo kinboster at gmail.com
Wed Aug 17 23:41:59 PDT 2011


hi all
     I need a systembus for example, the dbus-python haven't supply. So I
want to create a systembus myself,
the example I based on example-services.py under
the dbus-python-0.83.1/examples which  is python-dbus source code directory.
I do below step, and grab a failed:
1. modify example-services.py session_bus = dbus.SessionBus() to
session_bus = dbus.SystemBus().
2.create
 /usr/share/dbus-1/system-services/com.example.SampleService.service
[D-BUS Service]
Name=com.example.SampleService
Exec=/opt/examples/example-service.py
User=root
3.create /etc/dbus-1/system.d/com.example.SampleService.conf
<!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 could launch this service -->
  <policy user="root">
    <allow own="com.example.SampleService"/>
    <allow send_destination="com.example.SampleService"/>
    <allow send_interface="com.example.SampleService"/>
    <allow send_member="com.example.SampleService"/>
  </policy>

  <policy context="default">
    <allow send_destination="com.example.SampleService"
           send_interface="org.freedesktop.DBus.Introspectable"/>
    <allow send_destination="com.example.SampleService"
           send_member="RaiseException"/>
    <allow send_destination="com.example.SampleService"
           send_member="HelloWorld"/>
    <allow send_destination="com.example.SampleService"
           send_member="GetTuple"/>
    <allow send_destination="com.example.SampleService"
           send_member="GetDict"/>
    <allow send_destination="com.example.SampleService"
           send_member="Exit"/>
    <allow send_destination="com.example.SampleService"
           send_member="RaiseException"/>
  </policy>
</busconfig>

After above step, I run example-service.py manual: ./example-service.py
Traceback (most recent call last):
  File "./example-service.py", line 78, in <module>
    name = dbus.service.BusName("com.example.SampleService", session_bus)
  File "/usr/lib/pymodules/python2.6/dbus/service.py", line 129, in __new__
    retval = bus.request_name(name, name_flags)
  File "/usr/lib/pymodules/python2.6/dbus/bus.py", line 306, in request_name
    'su', (name, flags))
  File "/usr/lib/pymodules/python2.6/dbus/connection.py", line 630, in
call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied:
Connection ":1.48" is not allowed to own the service
"com.example.SampleService" due to security policies in the configuration
file

 Any ideas ?

--
Best Regards,
Qin Bo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20110818/ebca6f86/attachment.htm>


More information about the dbus mailing list