Bug 28979

Summary: dbus-daemon doesn't work when listen on TCP and system has no configured interfaces
Product: dbus Reporter: Pavel Strashkin <xaka2004>
Component: coreAssignee: D-Bus Maintainers <dbus>
Status: RESOLVED MOVED QA Contact: D-Bus Maintainers <dbus>
Severity: normal    
Priority: low CC: chengwei.yang.cn, msniko14, smcv
Version: 1.5   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Pavel Strashkin 2010-07-09 06:47:55 UTC
I'm on OpenSolaris, but sure 100% that it can be reproduced on any OS.

If you don't have configured network interfaces in the system (i.e. interfaces without IP address, except loopback) and want run dbus-daemon in TCP mode (tcp:host=*,port=3000) - it will exit with error "Failed to lookup host/port: node name or service name not known".

The reason is AI_ADDRCONFIG flag. If it set, then getaddrinfo returns E_NONAME because when that flag is set - loopback interfaces wil not be in result list
I think it's bug in dbus and that flag should be removed from dbus_listen_tcp_socket code.
AI_ADDRCONFIG described in http://www.faqs.org/rfcs/rfc3493.html
That flag make sence (but i'm not sure) only in _dbus_connect_tcp_socket, but not in _dbus_listen_tcp_socket.
Comment 1 Simon McVittie 2011-02-16 04:47:59 UTC
Could you please stop randomly assigning bugs to me? Asserting that I'm working on something doesn't make it true.

Your diagnosis looks correct to me, but I'd prefer someone with networking expertise to review this. I assume your proposed fix is to stop using AI_ADDRCONFIG in _dbus_listen_tcp_socket, in both sysdeps-unix and sysdeps-win?

Triaging to severity=normal, D-Bus over TCP isn't the normal configuration.
Comment 2 Chengwei Yang 2013-12-04 05:33:25 UTC
(In reply to comment #1)
> Could you please stop randomly assigning bugs to me? Asserting that I'm
> working on something doesn't make it true.
> 
> Your diagnosis looks correct to me, but I'd prefer someone with networking
> expertise to review this. I assume your proposed fix is to stop using
> AI_ADDRCONFIG in _dbus_listen_tcp_socket, in both sysdeps-unix and
> sysdeps-win?

I think yes. Meanwhile, I think AI_ADDRCONFIG shouldn't be used in both _dbus_listen_tcp_socket() and _dbus_connect_tcp_socket_with_nonce() because if it can only listen on loopback rather than any client can connect to loopback, it doesn't make any sense.

> 
> Triaging to severity=normal, D-Bus over TCP isn't the normal configuration.
Comment 3 Chengwei Yang 2013-12-04 06:52:56 UTC
Seems I can't reproduce this bug on Fedora 19 x86_64, sure in virtual machine.

1. No NIC expect loopback

[root@vm-fedora-19 ~]# ifconfig -a
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2. set session.conf to listen at tcp:host=*,port=0

<listen>tcp:host=*,port=0</listen>

3. start dbus-daemon

[chengwei@vm-fedora-19 dbus.git]$ ./tmp_install/bin/dbus-daemon --session --print-pid= --print-address=
tcp:host=*,port=55903,guid=d8d6440e93f0f06f8b98796e529ece37
14710

4. netstat -tlnp says

[chengwei@vm-fedora-19 dbus.git]$ netstat -tlnp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:55903           0.0.0.0:*               LISTEN      14710/./tmp_install 
tcp6       0      0 :::111                  :::*                    LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:631                 :::*                    LISTEN      -   

BTW, I'm testing this on HEAD of master branch.
Comment 4 Chengwei Yang 2013-12-04 07:37:46 UTC
However, basically I can reproduce this bug on FreeBSD 9.1 like below.

1. my NICs, with a configured NIC: em0

root@vm-freebsd-91:/root # ifconfig -a
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
        ether 52:54:00:49:b5:47
        inet 10.238.155.176 netmask 0xffffff00 broadcast 10.238.155.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
        inet 127.0.0.1 netmask 0xff000000 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

2. listen at <listen>tcp:host=*,port=0</listen>
$ ./tmp_install/bin/dbus-daemon --session --print-address= --print-pid=
Failed to start message bus: Failed to lookup host/port: "*:0": hostname nor servname provided, or not known (8)

3. listen at <listen>tcp:host=*,port=10000</listen>, I'm sure no others listen at port 10000 in tcp protocol.
$ ./tmp_install/bin/dbus-daemon --session --print-address= --print-pid=
Failed to start message bus: Failed to lookup host/port: "*:10000": hostname nor servname provided, or not known (8)

4. listen at <listen>tcp:host=localhost,port=0/listen>
$ ./tmp_install/bin/dbus-daemon --session --print-address= --print-pid=
tcp:host=localhost,port=28084,guid=d62e1c83020fa295555bb263529e6401
12337

5. listen at <listen>tcp:host=localhost,port=10000/listen>
$ ./tmp_install/bin/dbus-daemon --session --print-address= --print-pid=
tcp:host=localhost,port=10000,guid=11b23da193deb386988245ea529e648b
12367

So we can get some conclusions from above testing.

1. "*" isn't a valid hostname in FreeBSD 9.1
2. "port=0" works fine here.


OK, the next step is remove the configured NIC, em0 above and only left loopback address.

1. ifconfig -a output
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
        inet 127.0.0.1 netmask 0xff000000 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
2. listen at <listen>tcp:host=*,port=0</listen>
$ ./tmp_install/bin/dbus-daemon --session --print-address= --print-pid=
Failed to start message bus: Failed to lookup host/port: "*:0": hostname nor servname provided, or not known (8)

3. listen at <listen>tcp:host=localhost,port=0/listen>
$ ./tmp_install/bin/dbus-daemon --session --print-address= --print-pid=
tcp:host=localhost,port=59421,guid=3edfda12be9b28069cf8057c529e67ec
729

So seems AI_ADDRCONFIG isn't cause failure of getaddrinfo(3), Pavel Strashkin, could you confirm that on OpenSolaris?

I'll file a bug to track the "*" is invalid hostname on FreeBSD, maybe more UNIX OS.
Comment 5 Chengwei Yang 2013-12-04 09:53:54 UTC
Pavel Strashkin, if you can confirm that is "host=*" caused your problem on OpenSolaris, I think this is an invalid usage because dbus doesn't say "*" is a valid value of host, and in fact, "*" is invalid.

We may also output some notice to user/log like below.

pseudo code:

if host is "*"
  log ("'*' isn't a valid hostname, may fail on UNIX\n");
Comment 6 Simon McVittie 2013-12-04 12:37:02 UTC
(In reply to comment #5)
> Pavel Strashkin, if you can confirm that is "host=*" caused your problem on
> OpenSolaris, I think this is an invalid usage because dbus doesn't say "*"
> is a valid value of host, and in fact, "*" is invalid.

As far as I'm aware, the correct syntax to listen on all addresses is "tcp:host=0.0.0.0,port=3000" (or "tcp:port=3000", or just "tcp:" probably also works).

> pseudo code:
> 
> if host is "*"
>   log ("'*' isn't a valid hostname, may fail on UNIX\n");

I don't think that's worth it - we should just fix any documentation that claims that "*" is the right thing to use.
Comment 7 GitLab Migration User 2018-10-12 21:06:58 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/28.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.