org.freedesktop.DBus.Error.AccessDenied解决办法

运行自己用python写的dbus服务时,出现如下错误:

Traceback (most recent call last):
  File "./test.py", line 87, in 
    object = DeviceObject()
  File "./test.py", line 37, in __init__
    bus_name = dbus.service.BusName(Bus_Name,bus=dbus.SystemBus())
  File "/usr/lib/python2.7/dist-packages/dbus/service.py", line 131, in __new__
    retval = bus.request_name(name, name_flags)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 303, in request_name
    'su', (name, flags))
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Connection ":1.92" is not allowed to own the service "com.foxbryant.demo" due to security policies in the configuration file

解决方法:

/etc/dbus-1/system.d/目录下创建com.foxbryant.demo.conf (名称随意,以.conf结尾即可) 内容如下:




  
  
    
    
    
  

  
    
    
    
  




你可能感兴趣的:(Ubuntu,原创)