系统dbus不允许使用conf文件冲出所有权

我正在尝试创build一个在系统总线上运行的守护程序服务,在这个服务中,发送和接收这个服务的权限应该完全公开给任何人。 (安全不是这项服务的关注)。 当我尝试使用QtDbus(使用PyQt)注册服务时,出现以下错误:由于configuration文件中的安全策略,“Connection”:1.0“不允许拥有服务”org.dbus.arduino“ 。 这个其他堆栈溢出具有相同的错误,但由于某种原因在这种情况下根本没有帮助。 dbus_bus_request_name():不允许连接拥有该服务 。

通常情况下,你应该离开system.conf文件,并在system.d目录中添加你的权限“打出”configuration文件。 我已经这样做了,但似乎没有改变任何东西,无论我如何开放权限。 事实上,我几乎是积极的,不改变任何东西! 这是我的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> 

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

 <busconfig> <policy context="default"> <allow own="*"/> <allow own="org.dbus.arduino"/> <allow send_type="method_call" log="true"/> </policy> </busconfig> 

我甚至把文件的名字以az开头,这样它可能是最后一个被读入的文件。下面是system.conf文件,注意我在那里注释了“allow own”部分。 这是实现这个目标的唯一方法(也是最糟糕的“修复”)。

 <!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> 

我绝对必须使用系统总线,因为我将它部署在没有GUI的树莓派上(没有x11,也没有会话总线)。 我只能通过完全允许系统总线上的所有东西(安全性在这个设备上的安全性几乎没有什么大不了)才能使树莓派工作。 显然,我不能让我的开发机器上发生这种情况。 作为背景,我使用Opensuse 12.2和覆盆子pi是Debian Squeeze。 我不能拥有我的用户帐户的服务,也不是根,除非我完全打开权限,在这种情况下,它工作得很好。 我还会注意到,当我完全打开系统dbus时,我仍然不得不使用root将消息发送到守护进程(终止命令)。 我希望这个解决scheme能够通过一个特定的用户以root权限来运行。 我也可以只允许相同的用户和根发送消息的解决scheme。

感谢您的帮助,我确信它是一个小问题!

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

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