Linux dbus_bus_request_name():不允许连接拥有服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4560877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:19:36  来源:igfitidea点击:

dbus_bus_request_name (): Connections are not allowed to own the service

linuxdbusbusyboxavahi

提问by Mandy

I built a root filesystem on arm. It should run dbus-daemon and avahi-daemon, but when I try to run avahi-daemon

我在 arm 上构建了一个根文件系统。它应该运行 dbus-daemon 和 avahi-daemon,但是当我尝试运行时avahi-daemon

$ dbus-daemon --system
$ avahi-daemon

I get this message:

我收到这条消息:

Found user 'avahi' (UID 4) and group 'avahi' (GID 4).
Successfully dropped root privileges.
avahi-daemon 0.6.28 starting up.
WARNING: No NSS support for mDNS detected, consider installing nss-mdns! 
dbus_bus_request_name(): Connection ":1.0" is not allowed to own the service "org.freedesktop.Avahi" due to security policies in the configuration file
WARNING: Failed to contact D-Bus daemon.
avahi-daemon 0.6.28 exiting.

What is wrong? Is it about dbus configuration ?

怎么了?是关于 dbus 配置吗?

采纳答案by Tomtix

I had a similar problem, in my case the default avahi-dbus.conf that come with my system packet system just lack the last " </policy>" before " </busconfig>" which triggered this error.

我有一个类似的问题,在我的情况下,我的系统数据包系统附带的默认 avahi-dbus.conf 缺少触发此错误的最后一个“ </policy>”之前的“ </busconfig>”。

I first thought the problem didn't come from this file since a rapid look at it is not enough to find this kind of syntax error.

我首先认为问题不是来自这个文件,因为快速查看它并不足以发现这种语法错误。

回答by Jacek Konieczny

There are restrictions on what client can register what name on the system bus. Otherwise a user process could receive request intended for some system service. The restrictions are configured via the dbus-daemon configuration file, usually /etc/dbus-1/system.conf. In standard installations this file includes other config files, especially all in the /etc/dbus-1/system.d/directory, where service specific configurations are stored. This way DBus is usually configured for Avahi:

什么客户端可以在系统总线上注册什么名称是有限制的。否则,用户进程可能会收到针对某些系统服务的请求。这些限制是通过 dbus-daemon 配置文件配置的,通常是/etc/dbus-1/system.conf. 在标准安装中,此文件包括其他配置文件,尤其是所有在/etc/dbus-1/system.d/存储服务特定配置的目录中。这种方式通常为 Avahi 配置 DBus:

Example from my workstation:

来自我的工作站的示例:

$ cat /etc/dbus-1/system.d/avahi-dbus.conf 
<!DOCTYPE busconfig PUBLIC
          "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
          "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <!-- Only root or user avahi can own the Avahi service -->
  <policy user="avahi">
    <allow own="org.freedesktop.Avahi"/>
  </policy>
  <policy user="root">
    <allow own="org.freedesktop.Avahi"/>
  </policy>

  <!-- Allow anyone to invoke methods on Avahi server, except SetHostName -->
  <policy context="default">
    <allow send_destination="org.freedesktop.Avahi"/>
    <allow receive_sender="org.freedesktop.Avahi"/>

    <deny send_destination="org.freedesktop.Avahi"
          send_interface="org.freedesktop.Avahi.Server" send_member="SetHostName"/>
  </policy>

  <!-- Allow everything, including access to SetHostName to users of the group "adm" -->
  <policy group="adm">
    <allow send_destination="org.freedesktop.Avahi"/>
    <allow receive_sender="org.freedesktop.Avahi"/>
  </policy>
  <policy user="root">
    <allow send_destination="org.freedesktop.Avahi"/>
    <allow receive_sender="org.freedesktop.Avahi"/>
  </policy>
</busconfig>

Make sure you have these standard configuration files or a proper custom configuration in place.

确保您拥有这些标准配置文件或适当的自定义配置。

回答by gak

In my case I simply had to restart the dbus service.

就我而言,我只需要重新启动 dbus 服务。

This probably was because avahi inserted a dbus config file (/etc/dbus-1/system.d/avahi-dbus.conf) which wasn't detected automatically.

这可能是因为 avahi 插入了/etc/dbus-1/system.d/avahi-dbus.conf未自动检测到的 dbus 配置文件 ( )。