summaryrefslogtreecommitdiff
path: root/source4/libnet/libnet_site.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-02-25 12:47:38 +0100
committerAndrew Tridgell <tridge@samba.org>2010-02-26 13:22:12 +1100
commitb6737c1a7cfe68ff45a2114b48e99176dd32d2ae (patch)
tree2ad3f7d4c6d7e7e4499e4cb908f3050781d0aa1b /source4/libnet/libnet_site.c
parent314a926179b02d7139016e56abc63a037e60ba43 (diff)
downloadsamba-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_site.c')
-rw-r--r--source4/libnet/libnet_site.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/libnet/libnet_site.c b/source4/libnet/libnet_site.c
index 8a002b24a4..410fb4b517 100644
--- a/source4/libnet/libnet_site.c
+++ b/source4/libnet/libnet_site.c
@@ -25,6 +25,7 @@
#include "librpc/rpc/dcerpc.h"
#include "libcli/resolve/resolve.h"
#include "param/param.h"
+#include "lib/tsocket/tsocket.h"
/**
* 1. Setup a CLDAP socket.
@@ -41,6 +42,8 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li
struct cldap_socket *cldap = NULL;
struct cldap_netlogon search;
+ int ret;
+ struct tsocket_address *dest_address;
tmp_ctx = talloc_named(ctx, 0, "libnet_FindSite temp context");
if (!tmp_ctx) {
@@ -50,14 +53,24 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li
/* Resolve the site name. */
ZERO_STRUCT(search);
- search.in.dest_address = r->in.dest_address;
- search.in.dest_port = r->in.cldap_port;
+ search.in.dest_address = NULL;
+ search.in.dest_port = 0;
search.in.acct_control = -1;
search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
search.in.map_response = true;
+ ret = tsocket_address_inet_from_strings(tmp_ctx, "ip",
+ r->in.dest_address,
+ r->in.cldap_port,
+ &dest_address);
+ if (ret != 0) {
+ r->out.error_string = NULL;
+ status = map_nt_error_from_unix(errno);
+ return status;
+ }
+
/* we want to use non async calls, so we're not passing an event context */
- status = cldap_socket_init(tmp_ctx, NULL, NULL, NULL, &cldap);//TODO
+ status = cldap_socket_init(tmp_ctx, NULL, NULL, dest_address, &cldap);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
r->out.error_string = NULL;