s4:lib/socket: iface_list_wildcard() should only return "::" if we have ipv6 interfaces
authorStefan Metzmacher <metze@samba.org>
Sun, 10 Jul 2011 13:13:45 +0000 (15:13 +0200)
committerStefan Metzmacher <metze@samba.org>
Sun, 10 Jul 2011 15:11:14 +0000 (17:11 +0200)
If glibc has IPv6 support, but it's not enabled in the running kernel
we should not try to listen on "::".

metze

source4/lib/socket/interface.c

index d5b610fea7f9a50ae7b9c89c25f00e4396088365..42e19467688141120b3de72b60c65f1e0f79a3d3 100644 (file)
@@ -520,7 +520,19 @@ const char **iface_list_wildcard(TALLOC_CTX *mem_ctx, struct loadparm_context *l
 
 #ifdef HAVE_IPV6
        if (lpcfg_parm_bool(lp_ctx, NULL, "ipv6", "enable", true)) {
-               return str_list_add(ret, "::");
+               struct interface *local_interfaces = NULL;
+
+               load_interface_list(ret, lp_ctx, &local_interfaces);
+
+               if (iface_list_first_v6(local_interfaces)) {
+                       TALLOC_FREE(local_interfaces);
+                       /*
+                        * only add "::" if we have at least
+                        * one ipv6 interface
+                        */
+                       return str_list_add(ret, "::");
+               }
+               TALLOC_FREE(local_interfaces);
        }
 #endif