hi all<div> I need a systembus for example, the dbus-python haven't supply. So I want to create a systembus myself,</div><div>the example I based on example-services.py under the dbus-python-0.83.1/examples which is python-dbus source code directory.</div>
<div>I do below step, and grab a failed:</div><div>1. modify example-services.py session_bus = dbus.SessionBus() to session_bus = dbus.SystemBus().</div><div>2.create /usr/share/dbus-1/system-services/com.example.SampleService.service </div>
<div><div>[D-BUS Service]</div><div>Name=com.example.SampleService</div><div>Exec=/opt/examples/example-service.py</div><div>User=root</div></div><div>3.create /etc/dbus-1/system.d/com.example.SampleService.conf </div><div>
<div><!DOCTYPE busconfig PUBLIC</div><div> "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"</div><div> "<a href="http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd</a>"></div>
<div><busconfig></div><div> <!-- Only root could launch this service --></div><div> <policy user="root"></div><div> <allow own="com.example.SampleService"/></div><div> <allow send_destination="com.example.SampleService"/></div>
<div> <allow send_interface="com.example.SampleService"/></div><div> <allow send_member="com.example.SampleService"/></div><div> </policy></div><div> </div><div> <policy context="default"></div>
<div> <allow send_destination="com.example.SampleService"</div><div> send_interface="org.freedesktop.DBus.Introspectable"/></div><div> <allow send_destination="com.example.SampleService"</div>
<div> send_member="RaiseException"/></div><div> <allow send_destination="com.example.SampleService"</div><div> send_member="HelloWorld"/></div><div> <allow send_destination="com.example.SampleService"</div>
<div> send_member="GetTuple"/></div><div> <allow send_destination="com.example.SampleService"</div><div> send_member="GetDict"/></div><div> <allow send_destination="com.example.SampleService"</div>
<div> send_member="Exit"/></div><div> <allow send_destination="com.example.SampleService"</div><div> send_member="RaiseException"/></div><div> </policy></div>
<div></busconfig></div></div><div> </div><div>After above step, I run example-service.py manual: ./example-service.py </div><div>Traceback (most recent call last):</div><div> File "./example-service.py", line 78, in <module></div>
<div> name = dbus.service.BusName("com.example.SampleService", session_bus)</div><div> File "/usr/lib/pymodules/python2.6/dbus/service.py", line 129, in __new__</div><div> retval = bus.request_name(name, name_flags)</div>
<div> File "/usr/lib/pymodules/python2.6/dbus/bus.py", line 306, in request_name</div><div> 'su', (name, flags))</div><div> File "/usr/lib/pymodules/python2.6/dbus/connection.py", line 630, in call_blocking</div>
<div> message, timeout)</div><div>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</div>
<div><br></div><div> Any ideas ?</div><div><div><div><br></div>-- <br><font color="#888888">Best Regards,<br>
Qin Bo<br></font><br>
</div></div>