s4-ipv6: use iface_list_wildcard() to listen on IPv6
authorAndrew Tridgell <tridge@samba.org>
Thu, 12 May 2011 10:35:02 +0000 (12:35 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 6 Jun 2011 02:26:10 +0000 (12:26 +1000)
when we need to listen on a wildcard address, we now listen on a list
of sockets, usually 0.0.0.0 and ::

source4/cldap_server/cldap_server.c
source4/kdc/kdc.c
source4/ldap_server/ldap_server.c
source4/rpc_server/dcerpc_server.c
source4/smb_server/service_smb.c
source4/smb_server/smb_samba3.c
source4/web_server/web_server.c

index 8e79af407e884c82cafa3f7185096472400d8111..d5aa9f410f91b710400be026ab09129339550ed7 100644 (file)
@@ -158,8 +158,13 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l
        /* if we are allowing incoming packets from any address, then
           we need to bind to the wildcard address */
        if (!lpcfg_bind_interfaces_only(lp_ctx)) {
-               status = cldapd_add_socket(cldapd, lp_ctx, "0.0.0.0");
-               NT_STATUS_NOT_OK_RETURN(status);
+               const char **wcard = iface_list_wildcard(cldapd, lp_ctx);
+               NT_STATUS_HAVE_NO_MEMORY(wcard);
+               for (i=0; wcard[i]; i++) {
+                       status = cldapd_add_socket(cldapd, lp_ctx, wcard[i]);
+                       NT_STATUS_NOT_OK_RETURN(status);
+               }
+               talloc_free(wcard);
        }
 
        /* now we have to also listen on the specific interfaces,
index 02c6f925a9f39a44a517ef196962f51d113569ab..5620c0b2888d192d6ac347aaa77c37be60310c46 100644 (file)
@@ -734,19 +734,24 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
        /* if we are allowing incoming packets from any address, then
           we need to bind to the wildcard address */
        if (!lpcfg_bind_interfaces_only(lp_ctx)) {
-               if (kdc_port) {
-                       status = kdc_add_socket(kdc, model_ops,
-                                               "kdc", "0.0.0.0", kdc_port,
-                                               kdc_process, false);
-                       NT_STATUS_NOT_OK_RETURN(status);
-               }
-
-               if (kpasswd_port) {
-                       status = kdc_add_socket(kdc, model_ops,
-                                               "kpasswd", "0.0.0.0", kpasswd_port,
-                                               kpasswdd_process, false);
-                       NT_STATUS_NOT_OK_RETURN(status);
+               const char **wcard = iface_list_wildcard(kdc, lp_ctx);
+               NT_STATUS_HAVE_NO_MEMORY(wcard);
+               for (i=0; wcard[i]; i++) {
+                       if (kdc_port) {
+                               status = kdc_add_socket(kdc, model_ops,
+                                                       "kdc", wcard[i], kdc_port,
+                                                       kdc_process, false);
+                               NT_STATUS_NOT_OK_RETURN(status);
+                       }
+
+                       if (kpasswd_port) {
+                               status = kdc_add_socket(kdc, model_ops,
+                                                       "kpasswd", wcard[i], kpasswd_port,
+                                                       kpasswdd_process, false);
+                               NT_STATUS_NOT_OK_RETURN(status);
+                       }
                }
+               talloc_free(wcard);
                done_wildcard = true;
        }
 
index 01846add64eadcbd9abd981f3f23367acb947a3e..605a4a3cc2932f025b18d0b50399f638cf9cac58 100644 (file)
@@ -964,9 +964,18 @@ static void ldapsrv_task_init(struct task_server *task)
                        if (!NT_STATUS_IS_OK(status)) goto failed;
                }
        } else {
-               status = add_socket(task, task->lp_ctx, model_ops,
-                                   lpcfg_socket_address(task->lp_ctx), ldap_service);
-               if (!NT_STATUS_IS_OK(status)) goto failed;
+               const char **wcard;
+               int i;
+               wcard = iface_list_wildcard(task, task->lp_ctx);
+               if (wcard == NULL) {
+                       DEBUG(0,("No wildcard addresses available\n"));
+                       goto failed;
+               }
+               for (i=0; wcard[i]; i++) {
+                       status = add_socket(task, task->lp_ctx, model_ops, wcard[i], ldap_service);
+                       if (!NT_STATUS_IS_OK(status)) goto failed;
+               }
+               talloc_free(wcard);
        }
 
        ldapi_path = lpcfg_private_path(ldap_service, task->lp_ctx, "ldapi");
index fcf3f2f7e672bb9e04fb0c12e464c8be294b65b9..762221dc5b8ac3d7a63348f4f60f1864c331a5a6 100644 (file)
@@ -1687,9 +1687,15 @@ static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx,
                        NT_STATUS_NOT_OK_RETURN(status);
                }
        } else {
-               status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, 
-                                                 lpcfg_socket_address(lp_ctx));
-               NT_STATUS_NOT_OK_RETURN(status);
+               const char **wcard;
+               int i;
+               wcard = iface_list_wildcard(dce_ctx, lp_ctx);
+               NT_STATUS_HAVE_NO_MEMORY(wcard);
+               for (i=0; wcard[i]; i++) {
+                       status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, wcard[i]);
+                       NT_STATUS_NOT_OK_RETURN(status);
+               }
+               talloc_free(wcard);
        }
 
        return NT_STATUS_OK;
index 48666958657d08feb6266cdd3602bfe089cff532..d2833d9be60204a7410ff4936ac39495e667df5e 100644 (file)
@@ -63,9 +63,18 @@ static void smbsrv_task_init(struct task_server *task)
                }
        } else {
                /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */
-               status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops,
-                                          lpcfg_socket_address(task->lp_ctx));
-               if (!NT_STATUS_IS_OK(status)) goto failed;
+               const char **wcard;
+               int i;
+               wcard = iface_list_wildcard(task, task->lp_ctx);
+               if (wcard == NULL) {
+                       DEBUG(0,("No wildcard addresses available\n"));
+                       goto failed;
+               }
+               for (i=0; wcard[i]; i++) {
+                       status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, wcard[i]);
+                       if (!NT_STATUS_IS_OK(status)) goto failed;
+               }
+               talloc_free(wcard);
        }
 
        return;
index 86e67ec20da34100772c33e7166f65615ca296e9..35630ade0534114220e7b5d769f5813a6e29b28f 100644 (file)
@@ -152,12 +152,21 @@ static void samba3_smb_task_init(struct task_server *task)
                        if (!NT_STATUS_IS_OK(status)) goto failed;
                }
        } else {
-               /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */
-               status = samba3_add_socket(task,
-                                          task->event_ctx, task->lp_ctx,
-                                          model_ops,
-                                          lpcfg_socket_address(task->lp_ctx));
-               if (!NT_STATUS_IS_OK(status)) goto failed;
+               const char **wcard;
+               int i;
+               wcard = iface_list_wildcard(task, task->lp_ctx);
+               if (wcard == NULL) {
+                       DEBUG(0,("No wildcard addresses available\n"));
+                       goto failed;
+               }
+               for (i=0; wcard[i]; i++) {
+                       status = samba3_add_socket(task,
+                                                  task->event_ctx, task->lp_ctx,
+                                                  model_ops,
+                                                  wcard[i]);
+                       if (!NT_STATUS_IS_OK(status)) goto failed;
+               }
+               talloc_free(wcard);
        }
 
        return;
index ab8f63b2ec9f329b1339bc8d761176127394eea7..c43b2cfc7b17a268a8e9d6e86f45e1895eb703b4 100644 (file)
@@ -336,13 +336,23 @@ static void websrv_task_init(struct task_server *task)
 
                talloc_free(ifaces);
        } else {
-               status = stream_setup_socket(task, task->event_ctx,
-                                            task->lp_ctx, model_ops,
-                                            &web_stream_ops,
-                                            "ipv4", lpcfg_socket_address(task->lp_ctx),
-                                            &port, lpcfg_socket_options(task->lp_ctx),
-                                            task);
-               if (!NT_STATUS_IS_OK(status)) goto failed;
+               const char **wcard;
+               int i;
+               wcard = iface_list_wildcard(task, task->lp_ctx);
+               if (wcard == NULL) {
+                       DEBUG(0,("No wildcard addresses available\n"));
+                       goto failed;
+               }
+               for (i=0; wcard[i]; i++) {
+                       status = stream_setup_socket(task, task->event_ctx,
+                                                    task->lp_ctx, model_ops,
+                                                    &web_stream_ops,
+                                                    "ip", wcard[i],
+                                                    &port, lpcfg_socket_options(task->lp_ctx),
+                                                    wdata);
+                       if (!NT_STATUS_IS_OK(status)) goto failed;
+               }
+               talloc_free(wcard);
        }
 
        wdata->tls_params = tls_initialise(wdata, task->lp_ctx);