From b6737c1a7cfe68ff45a2114b48e99176dd32d2ae Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Feb 2010 12:47:38 +0100 Subject: s4:libnet: use a connected CLDAP socket. This is needed because we don't (want) to specify an explicit local address. And the socket family (ipv4 vs. ipv6) needs to be autodetected based on the remote address before the socket() syscall. Otherwise we would try to connect to a ipv4 address through an ipv6only socket. metze --- source4/libnet/libnet_unbecome_dc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source4/libnet/libnet_unbecome_dc.c') diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c index 6e1ecf072d..5fd0d55602 100644 --- a/source4/libnet/libnet_unbecome_dc.c +++ b/source4/libnet/libnet_unbecome_dc.c @@ -28,6 +28,7 @@ #include "../libds/common/flags.h" #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "param/param.h" +#include "lib/tsocket/tsocket.h" /***************************************************************************** * Windows 2003 (w2k3) does the following steps when changing the server role @@ -256,9 +257,11 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s) { struct composite_context *c = s->creq; struct tevent_req *req; + struct tsocket_address *dest_address; + int ret; - s->cldap.io.in.dest_address = s->source_dsa.address; - s->cldap.io.in.dest_port = lp_cldap_port(s->libnet->lp_ctx); + s->cldap.io.in.dest_address = NULL; + s->cldap.io.in.dest_port = 0; s->cldap.io.in.realm = s->domain.dns_name; s->cldap.io.in.host = s->dest_dsa.netbios_name; s->cldap.io.in.user = NULL; @@ -268,8 +271,17 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s) s->cldap.io.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; s->cldap.io.in.map_response = true; + ret = tsocket_address_inet_from_strings(s, "ip", + s->source_dsa.address, + lp_cldap_port(s->libnet->lp_ctx), + &dest_address); + if (ret != 0) { + c->status = map_nt_error_from_unix(errno); + if (!composite_is_ok(c)) return; + } + c->status = cldap_socket_init(s, s->libnet->event_ctx, - NULL, NULL, &s->cldap.sock);//TODO + NULL, dest_address, &s->cldap.sock); if (!composite_is_ok(c)) return; req = cldap_netlogon_send(s, s->cldap.sock, &s->cldap.io); -- cgit