Search code examples
dbus

Using D-Bus for multiple machines over the internet


I'm writing a server (in C) which serves different machines. I'd like to use D-Bus for remote procedure calls through Internet, but I heard that D-Bus can't be used for many machines, but for one machine. Is that right? Can I use D-Bus for this situation?


Solution

  • The short answer is yes, this is possible; dbus can be used across different machines (but please see the security caveats below).

    On your server the dbus-daemon configuration file (you probably want to setup a whole other bus just for your services and not reuse the system or session buses) will need to be configured to accept connections via TCP instead of just via a local socket in /tmp. There are some tricks to setting up the appropriate listen commands in dbus-daemon that are well documented.

    Additionally, if you can't modify the local dbus-daemon (or you are forced to use an old, broken version of dbus-daemon distributed with RHEL that won't listen on remote sockets) you can run an application called dbus-daemon-proxy which will listen on a socket and forward connections to the local dbus-daemon.

    Either way, on your client machine you will need to set the DBUS_SESSION_BUS_ADDRESS variable to have the IP address and port that dbus-daemon or the proxy server is listening on.

    Security Caveats: There is no encryption of data on the wire and the dbus access mechanisms only apply to the local connections, not the TCP connections. To properly secure dbus connections that use the TCP transport mechanism you will have a bit of work in front of you.