Система D-Bus не позволяет определять права собственности с помощью файлов conf
Я пытаюсь создать службу демона, которая работает на системной шине, где разрешения на отправку и получение от этой службы должны быть полностью открыты для всех. (Безопасность не является проблемой для этой услуги). Когда я пытаюсь зарегистрировать сервис, используя QtDbus (используя PyQt для него), я получаю эту ошибку:Connection ":1.0" is not allowed to own the service "org.dbus.arduino" due to security policies in the configuration file
, Это другое переполнение стека имеет ту же ошибку, но по какой-то причине вообще не помогает в этой ситуации.dbus_bus_request_name ()
: Соединениям не разрешено владеть сервисом.
Обычно вы должны покинутьsystem.conf
файл в такте и добавьте ваши разрешения "вырубить" файл конфигурации в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>
Даже если я делаю это или тому подобное, это все равно не работает.
<busconfig>
<policy context="default">
<allow own="*"/>
<allow own="org.dbus.arduino"/>
<allow send_type="method_call" log="true"/>
</policy>
</busconfig>
Я даже поместил имя файла, начинающегося с z, чтобы он мог быть последним, который читается. Вот файл 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>
Мне абсолютно необходимо использовать системную шину, потому что я развертываю ее на Raspberry Pi без графического интерфейса (без x11 и без сессионной шины). Мне удалось заставить работать Raspberry Pi, только полностью разрешив все на системной шине (безопасность на этом устройстве не такая уж большая проблема). Очевидно, я никак не могу допустить, чтобы это произошло на моей машине для разработки. В качестве фона я использую Opensuse 12.2, а Raspberry Pi - Debian Squeeze. Я не могу владеть сервисом ни с моей учетной записью, ни с правами root, если я полностью не открою разрешения, в этом случае он работает просто отлично. Также отмечу, что когда я полностью открыл системную шину, мне все равно пришлось использовать root для отправки сообщений демону (команда завершения). Мне бы хотелось, чтобы решение могло быть запущено через конкретного пользователя с правами root. Я также согласен с решением, позволяющим отправлять на него сообщения только одному пользователю и пользователю root.
Спасибо за любую помощь, я уверен, что это небольшая проблема!