Bug 72296

Summary: docs: don't suggest "*" as a hostname unless it is portable
Product: dbus Reporter: Chengwei Yang <chengwei.yang.cn>
Component: coreAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: D-Bus Maintainers <dbus>
Severity: enhancement    
Priority: low CC: alban.crequy, chengwei.yang.cn, msniko14, thiago, walters
Version: 1.5Keywords: patch
Hardware: All   
OS: All   
Whiteboard: review?
i915 platform: i915 features:
Attachments: Do not claim that '*' resolves to INADDR_ANY on all OSs

Description Chengwei Yang 2013-12-04 07:45:15 UTC
If a dbus-daemon configured to listen on tcp, like <listen>tcp:host=*,port=0</listen>, it will fail to start like

$ ./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)

For more test cases, see #bug28979
Comment 1 Chengwei Yang 2013-12-04 07:54:20 UTC
The FreeBSD 9.1 man page getaddrinfo(3) says something about hostname below.

     The hostname and servname arguments are either pointers to NUL-terminated
     strings or the null pointer.  An acceptable value for hostname is either
     a valid host name or a numeric host address string consisting of a dotted
     decimal IPv4 address or an IPv6 address.

So "*" isn't an acceptable value for hostname.
Comment 2 Chengwei Yang 2013-12-04 09:40:42 UTC
Just tried to find how the users learn that "*" is a valid value for host, in tcp/nonce-tcp transport. However, I didn't find that in both DBus Spec or dbus-daemon(1), so I'm curious, the only said in dbus-daemon is that

    The bind option can also take a special name '*' to cause the bus to listen 
    on all local address (INADDR_ANY)
Comment 3 Simon McVittie 2013-12-04 12:50:58 UTC
Which OS(s) do consider "*" to be a valid hostname?

As far as I'm concerned, the preferred syntax to express "listen on every IPv4 address" is 0.0.0.0 (which I believe is portable); omitting the "host" part entirely might also work.

If "host=*,port=3000" happens to work on Windows, or on platforms with GNU libc, or some other subset of platforms (because their libc resolver resolves * to 0.0.0.0), we shouldn't forbid that; but I also think we shouldn't recommend it, or go out of our way to make it more portable.

Analogously: localhost resolving to 127.0.0.1 is common, but not universal, and we should use host=127.0.0.1 in our defaults and documentation.
Comment 4 Simon McVittie 2014-09-11 14:05:09 UTC
The only mention of '*' that I can find is this, in dbus-daemon(1):

    <para>tcp/nonce-tcp addresses also allow a bind=hostname option,
    [...]
    or '*'
    to listen on all interfaces simultaneously.

    <para>Example: &lt;listen&gt;tcp:host=localhost,bind=*,port=0&lt;/listen&gt;</para>
Comment 5 Simon McVittie 2014-09-11 14:05:48 UTC
Created attachment 106134 [details] [review]
Do not claim that '*' resolves to INADDR_ANY on all OSs
Comment 6 Simon McVittie 2014-10-13 13:03:05 UTC
This documentation fix is a month old and has not had any comments, so I assume nobody has any objection to it. Fixed in git for 1.9.2.

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.