dbus

dbus填坑记录

  1. 如果普通用户登陆,不能用root用户创建DBUS_BUS_SESSION类型的dbus
  2. DBUS_BUS_SYSTEM类型需要在/etc/dbus-1/system.d/中增加定义,比如
    <busconfig>
            <policy user="root">
                    <allow own="uk.org.thekelleys.dnsmasq"/>
                    <allow send_destination="uk.org.thekelleys.dnsmasq"/>
            </policy>
            <policy context="default">
                    <deny own="uk.org.thekelleys.dnsmasq"/>
                    <deny send_destination="uk.org.thekelleys.dnsmasq"/>
            </policy>
    </busconfig>

     

  3. 普通用户sudo执行时,DBUS_BUS_SESSION类型和DBUS_BUS_SYSTEM不能通信。

DBUS_BUS_SESSION

这种类型的dbus不能用root用户创建,否则会报如下错误

dbus_bus_get failed: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

如果加上    setenv("DISPLAY", ":0", true);又会报如下错误

dbus_bus_get failed: /usr/bin/dbus-launch terminated abnormally with the following error: No protocol specified
Autolaunch error: X11 initialization failed.

DBUS_BUS_SYSTEM

直接用会报如下错误

dbus_bus_request_name failed: Connection ":1.21" is not allowed to own the service "xxx" due to security policies in the configuration file
dbus[19129]: Applications must not close shared connections - see dbus_connection_close() docs. This is a bug in the application.
  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted

必须在/etc/dbus-1/system.d/中增加相应的定义

dbus_bus_add_match

网上查到的粟子中,基本上都是type='signal',interface='%s',其实match的规则可以有很多,比如type, interface,sender,destination,所有的规则可以单独出现,也可以组合,实际使用中根据需要选择。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值