From 3c7ca00245bb28c9352146bb31f08e56c6197623 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 14 Feb 2018 14:13:50 +0100 Subject: [PATCH] Let dbus-daemon be more descriptive in case of ipv6 listen errors on Windows In case the host does not have ipv6 support and no family is specified in a tcp listen address dbus daemon prints out a cryptic message 'Failed to bind socket "localhost:xxx": Invalid argument', which is changed to 'Failed to start message bus: No ipv6 support available' with this patch. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922 --- dbus/dbus-sysdeps-win.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 4a456ec4..75042958 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1590,7 +1590,17 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, else if (!strcmp(family, "ipv4")) hints.ai_family = AF_INET; else if (!strcmp(family, "ipv6")) - hints.ai_family = AF_INET6; + { + if (_dbus_has_ipv6 ()) + hints.ai_family = AF_INET6; + else + { + dbus_set_error (error, + DBUS_ERROR_INVALID_ARGS, + "No ipv6 support available"); + return _dbus_socket_get_invalid (); + } + } else { dbus_set_error (error, @@ -1741,7 +1751,17 @@ _dbus_listen_tcp_socket (const char *host, else if (!strcmp(family, "ipv4")) hints.ai_family = AF_INET; else if (!strcmp(family, "ipv6")) - hints.ai_family = AF_INET6; + { + if (_dbus_has_ipv6 ()) + hints.ai_family = AF_INET6; + else + { + dbus_set_error (error, + DBUS_ERROR_INVALID_ARGS, + "No ipv6 support available", ""); + return -1; + } + } else { dbus_set_error (error, -- 2.12.3