DBus.Error.AccessDenied:已拒绝。通过TCP的DBUS

时间:2018-09-03 04:39:37

标签: python linux tcp dbus

借助以下Stackoverflow答案herehere,我能够通过TCP / IP成功地远程连接到系统DBUS。 并使用D-FEET可以验证连接。 enter image description here

从上面的屏幕截图可以看出,我能够访问远程总线,并且能够成功调用 org.freedesktop.hostname1 对象及其接口。

但是在尝试访问 com.aldogroup.Calculator 时,我抛出了以下异常 enter image description here

访问其他服务(例如org.bluez(我无法找到模式))时也会发生此 AccessDenied

更新

我的system.conf文件

<busconfig>                                                                     
        <listen>tcp:host=0.0.0.0,port=55557,family=ipv4</listen>                
        <listen>unix:tmpdir=/tmp</listen>                       

        <auth>ANONYMOUS</auth>                                  
        <allow_anonymous/>               
        <apparmor mode="disabled"/>
        <policy user="root">       
                <allow own="com.aldogroup.Calculator"/>
                <allow send_destination="com.aldogroup.Calculator"/>
                <allow send_interface="com.aldogroup.Calculator"/>  
                <allow send_type="method_call"/>                    
        </policy>                                                   
</busconfig>  

DBUS busctl输出

root@aldogroup-dart-6ul-1b6be6:~# busctl introspect com.aldogroup.Calculator /com/aldogroup/Calculator
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
com.aldogroup.Calculator            interface -         -            -
.Divide                             method    xx        x            -
.Multiply                           method    xx        x            -
org.freedesktop.DBus.Introspectable interface -         -            -
.Introspect                         method    -         s            -
org.freedesktop.DBus.Peer           interface -         -            -
.GetMachineId                       method    -         s            -
.Ping                               method    -         -            -
org.freedesktop.DBus.Properties     interface -         -            -
.Get                                method    ss        v            -
.GetAll                             method    s         a{sv}        -
.Set                                method    ssv       -            -
.PropertiesChanged                  signal    sa{sv}as  -            -

最诚挚的问候,

西蒙(Simon)

1 个答案:

答案 0 :(得分:0)

我通过在/etc/dbus-1/system.d /

中创建一个.conf文件来修复它
<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
    <policy user="root">
        <allow own="com.aldogroup.Calculator"/>
        <allow send_destination="com.aldogroup.Calculator"/>
        <allow send_interface="com.aldogroup.Calculator.Divide"/>
        <allow send_interface="com.aldogroup.Calculator.Multiply"/>
    </policy>
    <policy at_console="true">
        <allow send_destination="com.aldogroup.Calculator"/>
    </policy>
    <policy context="default">
        <allow send_destination="com.aldogroup.Calculator"/>
    </policy>
</busconfig>

不确定为什么system.conf中指定的策略没有完成这项工作。