DBus.Error.AccessDenied:被拒绝。基于 TCP 的 DBUS

2024-02-28

With the help of the following Stackoverflow answers here https://stackoverflow.com/a/13275973/1277793 and here https://stackoverflow.com/a/45487266/1277793 I was able to successfully connect to the system DBUS remotely over TCP/IP. And using D-FEET https://wiki.gnome.org/Apps/DFeet I'm able to verify the connection. enter image description here

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

But while attemtping to access the com.aldogroup.Calculator, I get the following exception thrown enter image description here

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

UPDATE

我的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总线输出

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


我通过在 /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 中指定的策略没有完成这项工作。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

DBus.Error.AccessDenied:被拒绝。基于 TCP 的 DBUS 的相关文章

随机推荐