我正在使用 gio,以及这个 DBus 实现来注册某个守护进程的内部对象。我使用 SESSION 范围的 Dbus 进行了所有测试,一切正常,但我尝试使用系统范围的注册,因为我的名称注册失败。
我正在使用 g_bus_own_name 获取名称,我的错误案例响应 bus_acquired_handler 然后 name_lost_handler 场景。
任何想法,我该如何解决这个问题,或者我如何获得有关错误的更多信息?
GIO:https://developer.gnome.org/gio/2.38/gio-Owning-Bus-Names.html#g-bus-own-name
这是 dbus-monitor 跟踪:
signal sender=org.freedesktop.DBus -> dest=:1.96 serial=2 path=/org/freedesktop/DBus;接口(interface)=org.freedesktop.DBus; member=NameAcquired
字符串 ":1.96"
signal sender=:1.95 -> dest=(null destination) serial=3 path=/org/ast/AstCore;接口(interface)=org.freedesktop.DBus.Properties;成员=属性更改
字符串“org.ast.AstCore”
数组 [
字典条目(
字符串“状态”
变体 int32 3
)
]
数组 [
]
signal sender=:1.95 -> dest=(null destination) serial=5 path=/org/ast/AstCore;接口(interface)=org.freedesktop.DBus.Properties;成员=属性更改
字符串“org.ast.AstCore”
数组 [
字典条目(
字符串“状态”
变体 int32 4
)
]
数组 [
]
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=173 path=/org/freedesktop/DBus;接口(interface)=org.freedesktop.DBus;成员=NameOwnerChanged
字符串 ":1.95"
字符串 ":1.95"
字符串 ""
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=174 path=/org/freedesktop/DBus;接口(interface)=org.freedesktop.DBus;成员=NameOwnerChanged
字符串“:1.97”
字符串""
字符串 ":1.97"
最佳答案
如/etc/dbus-1/system.conf 中所述
<!-- Holes must be punched in service configuration files for
name ownership and sending method calls -->
<deny own="*"/>
...
在/etc/dbus-1/system.d/中添加您自己的配置文件(例如 astcore.conf),以允许您的应用拥有特定的总线名称。
关于glib - DBus,未能获得系统范围的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20298962/