Linux SystemD-Bus不允许用conf文件冲出所有权

Linux SystemD-Bus不允许用conf文件冲出所有权,linux,configuration,dbus,qtdbus,Linux,Configuration,Dbus,Qtdbus,我正在尝试创建一个在系统总线上运行的守护程序服务,在这个系统总线上,任何人都可以完全打开发送和接收该服务的权限。(此服务不考虑安全性)。当我尝试使用QtDbus(使用PyQt)注册服务时,我得到以下错误:连接:1.0“由于配置文件中的安全策略,不允许拥有服务“org.dbus.arduino”。另一个堆栈溢出具有相同的错误,但由于某些原因,在这种情况下根本没有帮助 通常,您应该将system.conf文件保留在tact中,并将您的权限“punchout”配置文件添加到system.d目录中。我已

我正在尝试创建一个在系统总线上运行的守护程序服务,在这个系统总线上,任何人都可以完全打开发送和接收该服务的权限。(此服务不考虑安全性)。当我尝试使用QtDbus(使用PyQt)注册服务时,我得到以下错误:
连接:1.0“由于配置文件中的安全策略,不允许拥有服务“org.dbus.arduino”
。另一个堆栈溢出具有相同的错误,但由于某些原因,在这种情况下根本没有帮助

通常,您应该将
system.conf
文件保留在tact中,并将您的权限“punchout”配置文件添加到
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="myUser">
        <allow own="*"/>
        <allow own="org.dbus.arduino"/>
        <allow send_type="method_call" log="true"/>
    </policy>                 
    <policy user="root">        
        <allow own="*"/>
        <allow own="org.dbus.arduino"/>
        <allow send_type="method_call" log="true"/>
    </policy>                         
    <policy context="default">            
    </policy>                                                     
</busconfig>                 

即使我这样做或类似的事情,它仍然不起作用。


我甚至把文件名以z开头,这样它可能是最后一个被读入的文件。这是system.conf文件,请注意,我在其中注释了“允许自己”部分。这是让它工作的唯一方法(也是最糟糕的“修复”)


系统
消息总线
/lib/dbus-1/dbus守护进程启动帮助程序
/var/run/dbus/pid
外部的
unix:path=/var/run/dbus/system\u总线\u套接字
系统d
system-local.conf
上下文/dbus\u上下文
我必须使用系统总线,因为我将它部署在没有GUI的Raspberry Pi上(没有x11,也没有会话总线)。只有完全允许系统总线上的所有内容,我才能让Raspberry Pi正常工作(在这个设备上,安全性并没有那么重要)。显然,我不允许这种情况在我的开发机器上发生。作为背景,我使用Opensuse 12.2和树莓Pi是Debian挤压。除非我完全打开权限,否则我无法使用我的用户帐户或root拥有该服务,在这种情况下,它可以正常工作。我还将注意到,当我完全打开系统总线时,我仍然必须使用root向守护进程发送消息(terminate命令)。我希望这个解决方案能够通过一个特定的用户运行,并且root用户也可以访问。我也同意只允许同一用户和root用户向其发送消息的解决方案


谢谢你的帮助,我相信这是个小问题

我终于找到了问题所在。当Dbus查找用于清除权限(如所有权)的配置文件时,该文件不仅必须位于system.d/中,而且必须以.conf结尾


我的配置文件“org.dbus.arduino”应该是“org.dbus.arduino.conf”。我从system.conf中删除了代码。确认我不再有权限,在“system.d/org.dbus.arduino.conf”创建了一个配置文件,我被授予了权限。然后,我尝试将文件重命名为“org.dbus.arduino”,并确认权限被拒绝。

我使用了与相同的解决方案,但我也使用了此替代方案

我注意到在我的system.conf文件中,有这样一个注释:

对于本地配置更改,创建文件系统local.conf或 与此文件位于同一目录中的system.d/*.conf匹配的文件 包含配置指令的元素。这些 指令可以覆盖D-Bus或OS默认值

我没有将
.conf放在system.d/下,而是通过在与system.conf相同的目录中创建一个system-local.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 context="default">
    <allow own="dbus.my.own.service"/>
  </policy>
</busconfig>


是否有可以更改的arduino conf文件?您是否尝试过将
..
语句放在
system.conf
中,作为拒绝所有和允许所有之间的一个愉快的媒介?我不确定这里的语法,或者它是否会让你这么做。。。只是尝试帮助。或者尝试创建一个conf文件来匹配您的服务-例如
system.d/
中的
com.example.myservice.conf
和您想要的策略?好的,我已经100%确认system.d/中的各个conf文件存在某种问题。我按照您所说的做了,并将特定的服务所有权放在system.conf文件中的一个节点中。成功了。然后我将其删除,并将其放入system.d/no dice中的.conf文件中。不起作用。问题仍然存在,但是,这是可行的,我不是100%确定我想称之为“已回答”。我会等到下周再看是否还有其他人有什么想法。你看到了吗?我遇到了类似的问题。考虑使用会话总线,如:使用dbuslaunch启动会话总线,并将返回的env保存到一个已知文件中。在dbus服务器和客户机源中,使用env文件可以连接到会话总线。你觉得有什么缺点吗?
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- Our well-known bus type, do not change this -->
  <type>system</type>

  <!-- Run as special user -->
  <user>messagebus</user>

  <!-- Fork into daemon mode -->
  <fork/>

  <!-- We use system service launching using a helper -->
  <standard_system_servicedirs/>

  <!-- This is a setuid helper that is used to launch system services -->
  <servicehelper>/lib/dbus-1/dbus-daemon-launch-helper</servicehelper>

  <!-- Write a pid file -->
  <pidfile>/var/run/dbus/pid</pidfile>

  <!-- Enable logging to syslog -->
  <syslog/>

  <!-- Only allow socket-credentials-based authentication -->
  <auth>EXTERNAL</auth>

  <!-- Only listen on a local socket. (abstract=/path/to/socket 
       means use abstract namespace, don't really create filesystem 
       file; only Linux supports this. Use path=/whatever on other 
       systems.) -->
  <listen>unix:path=/var/run/dbus/system_bus_socket</listen>

  <policy context="default">
    <!-- All users can connect to system bus -->
    <allow user="*"/>

    <!-- Holes must be punched in service configuration files for
         name ownership and sending method calls -->
    <deny own="*"/>
    <deny send_type="method_call" log="true"/>

    <!-- THIS IS THE ONLY WAY TO GET THIS TO WORK
    <allow own="*"/>
    <allow send_type="method_call" log="true"/>
    -->



    <!-- Signals and reply messages (method returns, errors) are allowed
         by default -->
    <allow send_type="signal"/>
    <allow send_requested_reply="true" send_type="method_return"/>
    <allow send_requested_reply="true" send_type="error"/>

    <!-- All messages may be received by default -->
    <allow receive_type="method_call"/>
    <allow receive_type="method_return"/>
    <allow receive_type="error"/>
    <allow receive_type="signal"/>

    <!-- Allow anyone to talk to the message bus -->
    <allow send_destination="org.freedesktop.DBus"/>
    <!-- But disallow some specific bus services -->
    <deny send_destination="org.freedesktop.DBus"
          send_interface="org.freedesktop.DBus"
          send_member="UpdateActivationEnvironment"/>

  </policy>

  <!-- Config files are placed here that among other things, punch 
       holes in the above policy for specific services. -->
  <includedir>system.d</includedir>

  <!-- This is included last so local configuration can override what's 
       in this standard file -->
  <include ignore_missing="yes">system-local.conf</include>

  <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include>

</busconfig>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy context="default">
    <allow own="dbus.my.own.service"/>
  </policy>
</busconfig>