【问题标题】:DBus.Error.AccessDenied: Rejected. DBUS over TCPDBus.Error.AccessDenied:被拒绝。基于 TCP 的 DBUS
【发布时间】:2019-02-08 03:01:31
【问题描述】:

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

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

但在尝试访问 com.aldogroup.Calculator 时,我收到以下异常

这个AccessDenied在访问其他服务时也会出现,比如org.bluez(我一直没能找到模式)

更新

我的 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  -            -

最好的问候,

西蒙

【问题讨论】:

    标签: python linux tcp dbus


    【解决方案1】:

    我通过在 /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 中指定的策略不起作用。

    【讨论】:

      【解决方案2】:

      接受的答案中的解决方案对我来说不太适用。相反,我使用了以下内容:

      <?xml version="1.0" encoding="UTF-8"?>
      <!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="pi">
            <allow eavesdrop="true" />
            <allow eavesdrop="true" send_destination="*" />
            <allow own="com.example.calculator" />
         </policy>
      </busconfig>
      

      完成后,运行:

      sudo systemctl restart dbus
      

      【讨论】:

        猜你喜欢
        • 2011-10-28
        • 2016-08-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-23
        • 2018-10-01
        • 2012-10-08
        • 2020-02-25
        相关资源
        最近更新 更多