Search code examples
linuxembedded-linuxdbus

Linux DBus Remote TCP Connection with SystemD Fails


I am working on an Embedded Linux platform with SystemD Version 241 and a Linux Kernel Version 4.19.78.

I want to use D-Feet to remotely inspect various DBus interfaces.

I've done this in the past with an older version of SystemD using these instructions.

I've created a new DBus configuration file /usr/share/dbus-1/system.d/d-feet.conf:

<listen>tcp:host=localhost,bind=*,port=55556,family=ipv4</listen>
<listen>unix:tmpdir=/tmp</listen>

<busconfig>
  <auth>ANONYMOUS</auth>
  <allow_anonymous/>
</busconfig>

When I run netstat -plntu | grep 55556, I can see the port is bound:

tcp6       0      0 :::55556                :::*                    LISTEN      1/init

I have also edited the /lib/systemd/system/dbus.socket file:

[Unit]
Description=D-Bus System Message Bus Socket

[Socket]
ListenStream=/var/run/dbus/system_bus_socket
ListenStream=55556

However, when I try to connect from an Ubuntu 18.04 Linux machine on the same network, I see that it fails and is not offered the "ANONYMOUS" authentication method I have defined:

can not connect to 'tcp:host=192.168.1.16,port=55556': g-io-error-quark: Exhausted all available authentication mechanisms (tried: EXTERNAL) (available: EXTERNAL) (0)

How can I get this to work? Thank you.

UPDATE: I tried with '0.0.0.0' as the bind address:

<listen>tcp:host=localhost,bind=0.0.0.0,port=55556,family=ipv4</listen>
<listen>unix:tmpdir=/tmp</listen>

<busconfig>
  <auth>ANONYMOUS</auth>
  <allow_anonymous/>
</busconfig>

However, it still fails with the same error and the output of systemctl show dbus.socket includes the following:

PassCredentials=no
PassSecurity=no
RemoveOnStop=no
Listen=/var/run/dbus/system_bus_socket (Stream)
Listen=[::]:55556 (Stream)
Mark=-1
MaxConnections=64
MaxConnectionsPerSource=0
MessageQueueMaxMessages=0

Solution

  • I just stumbled across something that works. If I edit the /usr/share/dbus-1/system.conf file, and add the following:

    <busconfig>
       <listen>tcp:host=localhost,bind=0.0.0.0,port=55556,family=ipv4</listen>
       <listen>unix:tmpdir=/tmp</listen>
    
       <auth>ANONYMOUS</auth>
       <allow_anonymous/>
    </busconfig>
    

    It seems to work, if I do not do that, and rely on my changes in the d-feet.conf file, then it seems to fail.