The branch, master has been updated via d168a5e s4-ipv6: fill in family when initialising from sockaddr via 66aec3c s4-ipv6: removed the old unused ipv6 code in dcerpc_sock.c via 25ac58d s4-ipv6: fix the address family for IPv6 string addresses via 5d2dbf9 s4-ipv6: allow for IPv6 in dcerpc socket calls via d8e2302 s4-ipv6: allow for IPv6 in resolver top level calls via 3736f29 s4-ipv6: use the server address family via b81eac1 util-net: added is_ipaddress_v6() via d1c90c4 s4-ipv6: cope with IPv6 in our async DNS client code via 473b344 s4-script: install some of the samba scripts in bin/ during build via 0e1d7eb s4-testparm: testparm is now part of samba_tool via dc1e610 s4-ipv6: enable IPv6 by default via 0b11061 s4-ipv6: fixed binding to ipv4 addresses via be91eff s4-ipv6: removed an old comment via c4e43f9 s4-ipv6: don't add link local addresses to DNS via b34013d s4-ipv6: ensure wrepl server does not use ipv6 via 74a7e68 ipv6: always try to convert as a numeric address first via 7d59e9c s4-ipv6: added IPv6 support to samba_dnsupdate via 40dc94a s4-ipv6: update callers to load_interface_list() via 44d47e8 s4-ipv6: allow ipv6 to be enabled/disabled in smb.conf via 087ee1f s4-gpo: fixed display of GPO version numbers via 2f66fb92 s4-ipv6: the wins replication server can only handle IPv4 via 78a8087 s4-webserver: fixed a talloc reference error on startup failure via 1812dca s4-ipv6: only listen on V4 addresses in the NBT server via 8f3ce14 s4-ipv6: use "ip" instead of "ipv4" for servers via dc8c8fd s4-ipv6: use iface_list_wildcard() to listen on IPv6 via d510687 s4-ipv6: fixed stream_setup_socket() to handle IPv6 via df63248 s4-ipv6: fixed ipv6_listen() to use IPV6_V6ONLY via 244137b s4-ipv6: added socket_address_from_sockaddr_storage() via d8d63b5 s4-ipv6: added ipv4 functions to interface code via a527b96 s4-ipv6: fixed a warning via 62af4a3 s4-ipv6: allow IPv6 addresses in our interfaces list via 1c87f16 s4-ipv6: changed the default "socket address" via 2fc1151 s4-ipv6: added iface_list_wildcard() from 13ac91d nss_wins: Add a stackframe to lookup_byname_backend()
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit d168a5e703288a5fba3f35a6e44d3f5d5733e6c5 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 11:31:23 2011 +1000 s4-ipv6: fill in family when initialising from sockaddr Autobuild-User: Andrew Tridgell <tri...@samba.org> Autobuild-Date: Mon Jun 6 05:35:36 CEST 2011 on sn-devel-104 commit 66aec3cf67595c7aec5d10775892dad2538caf65 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 10:43:05 2011 +1000 s4-ipv6: removed the old unused ipv6 code in dcerpc_sock.c the code is now generic to both V4 and V6 commit 25ac58dccef5d1da9946aeb191d6b6c4ee8782cf Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 10:42:28 2011 +1000 s4-ipv6: fix the address family for IPv6 string addresses commit 5d2dbf93b3bfed193c6d8224be6e1d3af7e66d0f Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 10:13:41 2011 +1000 s4-ipv6: allow for IPv6 in dcerpc socket calls commit d8e2302330db1b4d1c5b29608823d46a03fd087a Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 10:13:20 2011 +1000 s4-ipv6: allow for IPv6 in resolver top level calls commit 3736f29696288f908aac4189aedfc7149c431caa Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 10:11:53 2011 +1000 s4-ipv6: use the server address family don't force v4 in connect_multi commit b81eac1e2b47b0f3885cfe8bb251eeb6245706f9 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 10:11:13 2011 +1000 util-net: added is_ipaddress_v6() commit d1c90c465ee3d0bf60daf23c8eb9510071426c97 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Jun 6 08:09:02 2011 +1000 s4-ipv6: cope with IPv6 in our async DNS client code commit 473b3446998ca49e6597e30f8bbca43fd7215769 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Jun 4 08:22:30 2011 +1000 s4-script: install some of the samba scripts in bin/ during build commit 0e1d7eb429a3c6b34ed659f86b8d7a92434acd37 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Jun 4 08:20:54 2011 +1000 s4-testparm: testparm is now part of samba_tool commit dc1e6109c8bcc21831defd443fcf42427706c642 Author: Andrew Tridgell <tri...@samba.org> Date: Sat Jun 4 07:59:54 2011 +1000 s4-ipv6: enable IPv6 by default it now passes all tests commit 0b11061b05cf6fdda8bf8a9be1a8da5b0cac1707 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Jun 3 17:57:57 2011 +1000 s4-ipv6: fixed binding to ipv4 addresses commit be91effc20b6454f2b71aaadff3ff02378df164f Author: Andrew Tridgell <tri...@samba.org> Date: Fri Jun 3 11:43:38 2011 +1000 s4-ipv6: removed an old comment the comment is not correct any more commit c4e43f9dff108f762eb1f7271ddb896b9b22e478 Author: Andrew Tridgell <tri...@samba.org> Date: Fri Jun 3 11:43:09 2011 +1000 s4-ipv6: don't add link local addresses to DNS these make no sense as DNS addresses commit b34013d5377926303d1ea60259f6853c8684cf8b Author: Andrew Tridgell <tri...@samba.org> Date: Thu Jun 2 18:20:13 2011 +1000 s4-ipv6: ensure wrepl server does not use ipv6 WINS only does IPv4 commit 74a7e68925c27b0bce26a4f6775b3d08ba1767e0 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Jun 2 17:10:17 2011 +1000 ipv6: always try to convert as a numeric address first This avoids unnecessary name lookups, plus it fixes a problem with using interpret_string_addr*() with the wildcard IPv6 address commit 7d59e9c549933c33182fbb0a7227be0eb69b4892 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Jun 2 17:09:17 2011 +1000 s4-ipv6: added IPv6 support to samba_dnsupdate commit 40dc94a53f4f0f5dee285daf486912b0996d5f3e Author: Andrew Tridgell <tri...@samba.org> Date: Thu Jun 2 15:40:28 2011 +1000 s4-ipv6: update callers to load_interface_list() commit 44d47e85157209f5aec1a6e0cd507c1084716816 Author: Andrew Tridgell <tri...@samba.org> Date: Thu Jun 2 15:39:54 2011 +1000 s4-ipv6: allow ipv6 to be enabled/disabled in smb.conf this adds the parametric option ipv6:enable=true/false It defaults to false for now, until the remaining issues with testing of ipv6 are resolved commit 087ee1f40e4821f719f592ef2b768afad5c9a175 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 22:53:26 2011 +0200 s4-gpo: fixed display of GPO version numbers commit 2f66fb9270fb5f1dc79adab0e5d8d941992a2a17 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 13:08:45 2011 +0200 s4-ipv6: the wins replication server can only handle IPv4 commit 78a8087213e0ae67d1071367dd304fd2e761216e Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:38:03 2011 +0200 s4-webserver: fixed a talloc reference error on startup failure commit 1812dca0aeb399254e652f91c00c31d9dd58a367 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:37:34 2011 +0200 s4-ipv6: only listen on V4 addresses in the NBT server NBT doesn't do IPv6 commit 8f3ce14ea744d721636d3e096ae1f021aae042bd Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:36:33 2011 +0200 s4-ipv6: use "ip" instead of "ipv4" for servers this allows stream_setup_socket() to work with both v4 and v6 addresses commit dc8c8fd9e4f85974cd0665e613d4422ba8dd900e Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:35:02 2011 +0200 s4-ipv6: use iface_list_wildcard() to listen on IPv6 when we need to listen on a wildcard address, we now listen on a list of sockets, usually 0.0.0.0 and :: commit d510687408c03291df767e0ccacebcd4a360646c Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:33:01 2011 +0200 s4-ipv6: fixed stream_setup_socket() to handle IPv6 for IP we now detect the address family from the address, rather than requiring the caller to specify it. commit df632483f18923430a6da595d07c9f241438e766 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:30:16 2011 +0200 s4-ipv6: fixed ipv6_listen() to use IPV6_V6ONLY this changes ipv6_listen() to use IPV6_V6ONLY, and to setup the right scope id for link local IPv6 addresses commit 244137b10d511dedb1798b90aa2f4c354c50a44e Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:29:21 2011 +0200 s4-ipv6: added socket_address_from_sockaddr_storage() this converts a struct sockaddr_storage to a struct socket_address commit d8d63b53b7beed80e9224ce8079c18da95b28247 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:27:37 2011 +0200 s4-ipv6: added ipv4 functions to interface code this adds iface_list_first_v4() and iface_list_n_is_v4(). The NBT server will use these to allow it to listen only for IPv4 addresses. commit a527b96c968037db2d699493a9017709d053f95a Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:27:01 2011 +0200 s4-ipv6: fixed a warning commit 62af4a3798995b0368625c0322bc9d5373bb0348 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:26:18 2011 +0200 s4-ipv6: allow IPv6 addresses in our interfaces list commit 1c87f166df7adf64f5b3b0b445bfc24911d9d4d8 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:25:51 2011 +0200 s4-ipv6: changed the default "socket address" this changes the default socket address to the empty string. This allows uses to specify 0.0.0.0 meaning to listen only on the IPv4 wildcard address. commit 2fc11518b7573bce3cdf2f2acf7dec024f22e9c6 Author: Andrew Tridgell <tri...@samba.org> Date: Thu May 12 12:23:35 2011 +0200 s4-ipv6: added iface_list_wildcard() this returns a list of wildcard address to listen on, when we don't have 'bind interfaces only' set. It is a list, not a single address, we need to listen separately for the IPv6 "::" address from the IPv4 0.0.0.0 address. This also takes account of the loadparm "socket address" option ----------------------------------------------------------------------- Summary of changes: lib/util/util_net.c | 24 +++- lib/util/util_net.h | 1 + libcli/nbt/tools/nmblookup.c | 2 +- selftest/target/Samba4.pm | 2 +- source4/cldap_server/cldap_server.c | 11 +- source4/cldap_server/netlogon.c | 2 +- source4/dns_server/dns_server.c | 2 +- source4/echo_server/echo_server.c | 2 +- source4/kdc/kdc.c | 31 ++-- source4/ldap_server/ldap_server.c | 25 ++- source4/lib/socket/connect_multi.c | 2 +- source4/lib/socket/interface.c | 90 +++++++++-- source4/lib/socket/socket.c | 63 +++++++- source4/lib/socket/socket.h | 4 + source4/lib/socket/socket_ip.c | 28 +++- source4/lib/socket/testsuite.c | 4 +- source4/lib/socket/wscript_build | 2 +- source4/libcli/resolve/bcast.c | 2 +- source4/libcli/resolve/dns_ex.c | 56 ++++---- source4/libcli/resolve/resolve.c | 6 +- source4/libcli/resolve/wins.c | 2 +- source4/libcli/wrepl/winsrepl.c | 2 +- source4/librpc/rpc/dcerpc_sock.c | 51 +----- source4/nbt_server/interfaces.c | 17 ++- source4/nbt_server/nbt_server.c | 2 +- source4/nbt_server/wins/wins_ldb.c | 2 +- source4/nbt_server/wins/winsserver.c | 2 +- source4/param/loadparm.c | 2 +- source4/rpc_server/dcerpc_server.c | 16 ++- source4/scripting/bin/samba_dnsupdate | 40 ++++- source4/scripting/bin/setup_dns.sh | 2 +- source4/scripting/bin/testparm | 219 -------------------------- source4/scripting/bin/wscript_build | 5 + source4/scripting/python/pyglue.c | 2 +- source4/scripting/python/samba/netcmd/gpo.py | 2 +- source4/scripting/wscript_build | 4 +- source4/setup/dns_update_list | 2 + source4/smb_server/service_smb.c | 18 ++- source4/smb_server/smb_samba3.c | 23 ++- source4/smb_server/smb_server.c | 2 +- source4/smbd/service_stream.c | 45 +++-- source4/torture/nbt/dgram.c | 6 +- source4/torture/nbt/register.c | 4 +- source4/torture/nbt/wins.c | 2 +- source4/torture/nbt/winsbench.c | 2 +- source4/torture/nbt/winsreplication.c | 2 +- source4/torture/rpc/spoolss_notify.c | 2 +- source4/web_server/web_server.c | 34 +++-- source4/web_server/web_server.h | 1 + source4/wrepl_server/wrepl_in_connection.c | 8 +- source4/wrepl_server/wrepl_server.c | 4 +- 51 files changed, 451 insertions(+), 433 deletions(-) delete mode 100755 source4/scripting/bin/testparm create mode 100644 source4/scripting/bin/wscript_build Changeset truncated at 500 lines: diff --git a/lib/util/util_net.c b/lib/util/util_net.c index 98eef3b..64aa674 100644 --- a/lib/util/util_net.c +++ b/lib/util/util_net.c @@ -54,6 +54,15 @@ bool interpret_string_addr_internal(struct addrinfo **ppres, /* By default make sure it supports TCP. */ hints.ai_socktype = SOCK_STREAM; + + /* always try as a numeric host first. This prevents unnecessary name + * lookups, and also ensures we accept IPv6 addresses */ + hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; + ret = getaddrinfo(str, NULL, &hints, ppres); + if (ret == 0) { + return true; + } + hints.ai_flags = flags; /* Linux man page on getaddrinfo() says port will be @@ -297,10 +306,10 @@ bool is_ipaddress_v4(const char *str) } /** - * Return true if a string could be an IPv4 or IPv6 address. + * Return true if a string could be a IPv6 address. */ -bool is_ipaddress(const char *str) +bool is_ipaddress_v6(const char *str) { #if defined(HAVE_IPV6) int ret = -1; @@ -328,7 +337,16 @@ bool is_ipaddress(const char *str) } } #endif - return is_ipaddress_v4(str); + return false; +} + +/** + * Return true if a string could be an IPv4 or IPv6 address. + */ + +bool is_ipaddress(const char *str) +{ + return is_ipaddress_v4(str) || is_ipaddress_v6(str); } /** diff --git a/lib/util/util_net.h b/lib/util/util_net.h index 38b6d5a..fc2776a 100644 --- a/lib/util/util_net.h +++ b/lib/util/util_net.h @@ -85,6 +85,7 @@ _PUBLIC_ uint32_t interpret_addr(const char *str); _PUBLIC_ struct in_addr interpret_addr2(const char *str); _PUBLIC_ bool is_ipaddress_v4(const char *str); +_PUBLIC_ bool is_ipaddress_v6(const char *str); bool is_address_any(const struct sockaddr *psa); bool same_net(const struct sockaddr *ip1, diff --git a/libcli/nbt/tools/nmblookup.c b/libcli/nbt/tools/nmblookup.c index f6117f2..9b875b0 100644 --- a/libcli/nbt/tools/nmblookup.c +++ b/libcli/nbt/tools/nmblookup.c @@ -357,7 +357,7 @@ int main(int argc, const char *argv[]) exit(1); } - load_interface_list(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces); + load_interface_list(NULL, cmdline_lp_ctx, &ifaces); ev = s4_event_context_init(talloc_autofree_context()); diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index d27ee41..49bab37 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -658,7 +658,7 @@ nogroup:x:65534:nobody my $configuration = "--configfile=$ctx->{smb_conf}"; #Ensure the config file is valid before we start - my $testparm = $self->scriptdir_path("bin/testparm"); + my $testparm = Samba::bindir_path($self, "samba-tool") . " testparm"; if (system("$testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) { system("$testparm -v --suppress-prompt $configuration >&2"); warn("Failed to create a valid smb.conf configuration $testparm!"); diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c index 8e79af4..9370c59 100644 --- a/source4/cldap_server/cldap_server.c +++ b/source4/cldap_server/cldap_server.c @@ -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, @@ -184,7 +189,7 @@ static void cldapd_task_init(struct task_server *task) NTSTATUS status; struct interface *ifaces; - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); if (iface_list_count(ifaces) == 0) { task_server_terminate(task, "cldapd: no network interfaces configured", false); diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c index 3f3da8b..e950d70 100644 --- a/source4/cldap_server/netlogon.c +++ b/source4/cldap_server/netlogon.c @@ -291,7 +291,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, client_site = samdb_client_site_name(sam_ctx, mem_ctx, src_address, NULL); NT_STATUS_HAVE_NO_MEMORY(client_site); - load_interface_list(mem_ctx, lpcfg_interfaces(lp_ctx), &ifaces); + load_interface_list(mem_ctx, lp_ctx, &ifaces); /* * TODO: the caller should pass the address which the client * used to trigger this call, as the client is able to reach diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c index 2c0a379..de8bc12 100644 --- a/source4/dns_server/dns_server.c +++ b/source4/dns_server/dns_server.c @@ -617,7 +617,7 @@ static void dns_task_init(struct task_server *task) break; } - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); if (iface_list_count(ifaces) == 0) { task_server_terminate(task, "dns: no network interfaces configured", false); diff --git a/source4/echo_server/echo_server.c b/source4/echo_server/echo_server.c index 2a4a0bb..9393a97 100644 --- a/source4/echo_server/echo_server.c +++ b/source4/echo_server/echo_server.c @@ -308,7 +308,7 @@ static void echo_task_init(struct task_server *task) break; } - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); if (iface_list_count(ifaces) == 0) { task_server_terminate(task, diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index 02c6f92..7f7782c 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -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; } @@ -895,7 +900,7 @@ static void kdc_task_init(struct task_server *task) break; } - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); if (iface_list_count(ifaces) == 0) { task_server_terminate(task, "kdc: no network interfaces configured", false); diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index 01846ad..2d45766 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -815,7 +815,7 @@ static NTSTATUS add_socket(struct task_server *task, status = stream_setup_socket(task, task->event_ctx, lp_ctx, model_ops, &ldap_stream_nonpriv_ops, - "ipv4", address, &port, + "ip", address, &port, lpcfg_socket_options(lp_ctx), ldap_service); if (!NT_STATUS_IS_OK(status)) { @@ -830,7 +830,7 @@ static NTSTATUS add_socket(struct task_server *task, status = stream_setup_socket(task, task->event_ctx, lp_ctx, model_ops, &ldap_stream_nonpriv_ops, - "ipv4", address, &port, + "ip", address, &port, lpcfg_socket_options(lp_ctx), ldap_service); if (!NT_STATUS_IS_OK(status)) { @@ -852,7 +852,7 @@ static NTSTATUS add_socket(struct task_server *task, status = stream_setup_socket(task, task->event_ctx, lp_ctx, model_ops, &ldap_stream_nonpriv_ops, - "ipv4", address, &port, + "ip", address, &port, lpcfg_socket_options(lp_ctx), ldap_service); if (!NT_STATUS_IS_OK(status)) { @@ -866,7 +866,7 @@ static NTSTATUS add_socket(struct task_server *task, status = stream_setup_socket(task, task->event_ctx, lp_ctx, model_ops, &ldap_stream_nonpriv_ops, - "ipv4", address, &port, + "ip", address, &port, lpcfg_socket_options(lp_ctx), ldap_service); if (!NT_STATUS_IS_OK(status)) { @@ -951,7 +951,7 @@ static void ldapsrv_task_init(struct task_server *task) int num_interfaces; int i; - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); num_interfaces = iface_list_count(ifaces); /* We have been given an interfaces line, and been @@ -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"); diff --git a/source4/lib/socket/connect_multi.c b/source4/lib/socket/connect_multi.c index e3b5845..4ce5115 100644 --- a/source4/lib/socket/connect_multi.c +++ b/source4/lib/socket/connect_multi.c @@ -136,7 +136,7 @@ static void connect_multi_next_socket(struct composite_context *result) if (composite_nomem(state, result)) return; state->result = result; - result->status = socket_create("ipv4", SOCKET_TYPE_STREAM, &state->sock, 0); + result->status = socket_create(multi->server_address->family, SOCKET_TYPE_STREAM, &state->sock, 0); if (!composite_is_ok(result)) return; state->addr = socket_address_copy(state, multi->server_address); diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c index b762f55..96cee2f 100644 --- a/source4/lib/socket/interface.c +++ b/source4/lib/socket/interface.c @@ -21,6 +21,7 @@ #include "includes.h" #include "system/network.h" +#include "param/param.h" #include "lib/socket/netif.h" #include "../lib/util/util_net.h" #include "../lib/util/dlinklist.h" @@ -74,7 +75,8 @@ static struct interface *iface_list_find(struct interface *interfaces, /**************************************************************************** add an interface to the linked list of interfaces ****************************************************************************/ -static void add_interface(TALLOC_CTX *mem_ctx, const struct iface_struct *ifs, struct interface **interfaces) +static void add_interface(TALLOC_CTX *mem_ctx, const struct iface_struct *ifs, struct interface **interfaces, + bool enable_ipv6) { char addr[INET6_ADDRSTRLEN]; struct interface *iface; @@ -91,8 +93,7 @@ static void add_interface(TALLOC_CTX *mem_ctx, const struct iface_struct *ifs, s return; } - if (ifs->ip.ss_family != AF_INET) { - DEBUG(5, ("not adding IPv6 interface %s\n", ifs->name)); + if (!enable_ipv6 && ifs->ip.ss_family != AF_INET) { return; } @@ -151,7 +152,8 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, const char *token, struct iface_struct *probed_ifaces, int total_probed, - struct interface **local_interfaces) + struct interface **local_interfaces, + bool enable_ipv6) { struct sockaddr_storage ss; struct sockaddr_storage ss_mask; @@ -167,7 +169,7 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, for (i=0;i<total_probed;i++) { if (gen_fnmatch(token, probed_ifaces[i].name) == 0) { add_interface(mem_ctx, &probed_ifaces[i], - local_interfaces); + local_interfaces, enable_ipv6); added = true; } } @@ -187,7 +189,7 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, for (i=0;i<total_probed;i++) { if (sockaddr_equal((struct sockaddr *)&ss, (struct sockaddr *)&probed_ifaces[i].ip)) { add_interface(mem_ctx, &probed_ifaces[i], - local_interfaces); + local_interfaces, enable_ipv6); return; } } @@ -257,7 +259,7 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, p, probed_ifaces[i].name)); add_interface(mem_ctx, &probed_ifaces[i], - local_interfaces); + local_interfaces, enable_ipv6); probed_ifaces[i].netmask = saved_mask; return; } @@ -280,19 +282,20 @@ static void interpret_interface(TALLOC_CTX *mem_ctx, ifs.netmask = ss_mask; ifs.bcast = ss_bcast; add_interface(mem_ctx, &ifs, - local_interfaces); + local_interfaces, enable_ipv6); } /** load the list of network interfaces **/ -void load_interface_list(TALLOC_CTX *mem_ctx, const char **interfaces, struct interface **local_interfaces) +void load_interface_list(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct interface **local_interfaces) { - const char **ptr = interfaces; + const char **ptr = lpcfg_interfaces(lp_ctx); int i; struct iface_struct *ifaces; int total_probed; + bool enable_ipv6 = lpcfg_parm_bool(lp_ctx, NULL, "ipv6", "enable", true); *local_interfaces = NULL; @@ -306,14 +309,14 @@ void load_interface_list(TALLOC_CTX *mem_ctx, const char **interfaces, struct in DEBUG(0,("ERROR: Could not determine network interfaces, you must use a interfaces config line\n")); } for (i=0;i<total_probed;i++) { - if (!is_loopback_addr(&ifaces[i].ip)) { - add_interface(mem_ctx, &ifaces[i], local_interfaces); + if (!is_loopback_addr((struct sockaddr *)&ifaces[i].ip)) { + add_interface(mem_ctx, &ifaces[i], local_interfaces, enable_ipv6); } } } while (ptr && *ptr) { - interpret_interface(mem_ctx, *ptr, ifaces, total_probed, local_interfaces); + interpret_interface(mem_ctx, *ptr, ifaces, total_probed, local_interfaces, enable_ipv6); ptr++; } @@ -352,6 +355,38 @@ const char *iface_list_n_ip(struct interface *ifaces, int n) return NULL; } + +/** + return the first IPv4 interface address we have registered + **/ +const char *iface_list_first_v4(struct interface *ifaces) +{ + struct interface *i; + + for (i=ifaces; i; i=i->next) { + if (i->ip.ss_family == AF_INET) { + return i->ip_s; + } + } + return NULL; +} + +/** + check if an interface is IPv4 + **/ +bool iface_list_n_is_v4(struct interface *ifaces, int n) +{ + struct interface *i; + + for (i=ifaces;i && n;i=i->next) + n--; + + if (i) { + return i->ip.ss_family == AF_INET; + } + return false; +} + /** return bcast of the Nth interface **/ @@ -428,3 +463,32 @@ bool iface_list_same_net(const char *ip1, const char *ip2, const char *netmask) interpret_addr2(ip2), interpret_addr2(netmask)); } + +/** + return the list of wildcard interfaces + this will include the IPv4 0.0.0.0, and may include IPv6 :: + it is overridden by the 'socket address' option in smb.conf +*/ +const char **iface_list_wildcard(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) +{ + const char **ret; + const char *socket_address; + + /* the user may have configured a specific address */ + socket_address = lpcfg_socket_address(lp_ctx); + if (strcmp(socket_address, "") != 0) { + ret = (const char **)str_list_make(mem_ctx, socket_address, NULL); + return ret; + } + + ret = (const char **)str_list_make(mem_ctx, "0.0.0.0", NULL); + if (ret == NULL) return NULL; + +#ifdef HAVE_IPV6 + if (lpcfg_parm_bool(lp_ctx, NULL, "ipv6", "enable", true)) { + return str_list_add(ret, "::"); + } +#endif + + return ret; +} diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index cecd102..b16e38c 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -473,6 +473,11 @@ _PUBLIC_ struct socket_address *socket_address_from_strings(TALLOC_CTX *mem_ctx, return NULL; } + if (strcmp(family, "ip") == 0 && is_ipaddress_v6(host)) { + /* leaving as "ip" would force IPv4 */ + family = "ipv6"; + } + addr->family = family; addr->addr = talloc_strdup(addr, host); if (!addr->addr) { @@ -498,7 +503,19 @@ _PUBLIC_ struct socket_address *socket_address_from_sockaddr(TALLOC_CTX *mem_ctx if (!addr) { return NULL; } - addr->family = NULL; + switch (sockaddr->sa_family) { + case AF_INET: + addr->family = "ipv4"; + break; +#ifdef HAVE_IPV6 -- Samba Shared Repository