2

I'm using the zbus crate to make a server able to get events from the dbus. It works well my code (basically the same as the example from the documentation) is able to receive events so it's fine.

I use busctl to send an event like in the example:

busctl --user call org.zbus.MyGreeter /org/zbus/MyGreeter org.zbus.MyGreeter1 SayHello s "Maria"

And my code is able to receive the event with the parameter just fine.

The thing is I'm having some issues with udev and while I was trying to fix it I found some weird things:

  • If I send an event with another user it fails with Call failed: the name org.zbus.MyGreeter was not provided by any .service files while my program is running
  • When I do busctl list --acquired I don't see org.zbus.MyGreeter in the result

My question is: is it normal my program does not appear in the busctl list? Am I doing something wrong or do I use the wrong library to do what I want to do?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Yuutsuna
  • 192
  • 2
  • 13
  • 3
    There are at least two D-Bus instances running: a "system" instance accessible to everyone and "user" instances for each user. Since your program connects to the "user" bus, it is only available for that specific user and not on other user's buses. – Jmb Mar 17 '22 at 11:03

1 Answers1

3

Ok it seems there are 2 busses and I was not using the system bus. I had to replace the method session to system to indicates I want my program to run on the system bus. Like this:

let _ = ConnectionBuilder::system()?
        .name("org.zbus.MyGreeter")?
        .serve_at("/org/zbus/MyGreeter", greeter)?
        .build()
        .await?;

Doing this is not enough because my program does not have to permission to create a service on the bus system. So I had to create a file in /usr/share/dbus-1/system.d where I did write the configuration needed.

Yuutsuna
  • 192
  • 2
  • 13