diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-02-25 12:47:38 +0100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-02-26 13:22:12 +1100 |
commit | b6737c1a7cfe68ff45a2114b48e99176dd32d2ae (patch) | |
tree | 2ad3f7d4c6d7e7e4499e4cb908f3050781d0aa1b /source4/libnet/libnet_unbecome_dc.c | |
parent | 314a926179b02d7139016e56abc63a037e60ba43 (diff) | |
download | samba-b6737c1a7cfe68ff45a2114b48e99176dd32d2ae.tar.gz samba-b6737c1a7cfe68ff45a2114b48e99176dd32d2ae.tar.bz2 samba-b6737c1a7cfe68ff45a2114b48e99176dd32d2ae.zip |
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
Diffstat (limited to 'source4/libnet/libnet_unbecome_dc.c')
-rw-r--r-- | source4/libnet/libnet_unbecome_dc.c | 18 |
1 files changed, 15 insertions, 3 deletions
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); |