summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-12-21 21:55:01 +0100
committerVolker Lendecke <vl@samba.org>2010-12-22 16:39:15 +0100
commit5d4ac40f69aed6de033c0ca637dbab02db01740b (patch)
treeb4132506dcc021453ee5e7520a7bf059cf234418
parentd5188fcd185f518c2b2b78f9e4aa6c49b3d139c7 (diff)
downloadsamba-5d4ac40f69aed6de033c0ca637dbab02db01740b.tar.gz
samba-5d4ac40f69aed6de033c0ca637dbab02db01740b.tar.bz2
samba-5d4ac40f69aed6de033c0ca637dbab02db01740b.zip
s3: Use smbsock_any_connect in winbind
-rw-r--r--source3/winbindd/winbindd_cm.c58
1 files changed, 13 insertions, 45 deletions
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 8f641b56d7..3f21db511b 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -844,21 +844,6 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain,
goto done;
}
- if (ntohs(peeraddr_in->sin_port) == 139) {
- struct nmb_name calling;
- struct nmb_name called;
-
- make_nmb_name(&calling, global_myname(), 0x0);
- make_nmb_name(&called, "*SMBSERVER", 0x20);
-
- if (!cli_session_request(*cli, &calling, &called)) {
- DEBUG(8, ("cli_session_request failed for %s\n",
- controller));
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
- }
-
result = cli_negprot(*cli);
if (!NT_STATUS_IS_OK(result)) {
@@ -1368,7 +1353,10 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx,
struct sockaddr_storage *addrs = NULL;
int num_addrs = 0;
- int i, fd_index;
+ int i;
+ size_t fd_index;
+
+ NTSTATUS status;
*fd = -1;
@@ -1386,15 +1374,6 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx,
&addrs, &num_addrs)) {
return False;
}
-
- if (!add_string_to_array(mem_ctx, dcs[i].name,
- &dcnames, &num_dcnames)) {
- return False;
- }
- if (!add_sockaddr_to_array(mem_ctx, &dcs[i].ss, 139,
- &addrs, &num_addrs)) {
- return False;
- }
}
if ((num_dcnames == 0) || (num_dcnames != num_addrs))
@@ -1403,14 +1382,15 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx,
if ((addrs == NULL) || (dcnames == NULL))
return False;
- /* 5 second timeout. */
- if (!open_any_socket_out(addrs, num_addrs, 5000, &fd_index, fd) ) {
+ status = smbsock_any_connect(addrs, dcnames, num_addrs,
+ fd, &fd_index, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
for (i=0; i<num_dcs; i++) {
char ab[INET6_ADDRSTRLEN];
print_sockaddr(ab, sizeof(ab), &dcs[i].ss);
- DEBUG(10, ("find_new_dc: open_any_socket_out failed for "
+ DEBUG(10, ("find_new_dc: smbsock_any_connect failed for "
"domain %s address %s. Error was %s\n",
- domain->name, ab, strerror(errno) ));
+ domain->name, ab, nt_errstr(status) ));
winbind_add_failed_connection_entry(domain,
dcs[i].name, NT_STATUS_UNSUCCESSFUL);
}
@@ -1512,23 +1492,11 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
&& NT_STATUS_IS_OK(check_negative_conn_cache( domain->name, domain->dcname))
&& (resolve_name(domain->dcname, &domain->dcaddr, 0x20, true)))
{
- struct sockaddr_storage *addrs = NULL;
- int num_addrs = 0;
- int dummy = 0;
-
- if (!add_sockaddr_to_array(mem_ctx, &domain->dcaddr, 445, &addrs, &num_addrs)) {
- set_domain_offline(domain);
- talloc_destroy(mem_ctx);
- return NT_STATUS_NO_MEMORY;
- }
- if (!add_sockaddr_to_array(mem_ctx, &domain->dcaddr, 139, &addrs, &num_addrs)) {
- set_domain_offline(domain);
- talloc_destroy(mem_ctx);
- return NT_STATUS_NO_MEMORY;
- }
+ NTSTATUS status;
- /* 5 second timeout. */
- if (!open_any_socket_out(addrs, num_addrs, 5000, &dummy, &fd)) {
+ status = smbsock_connect(&domain->dcaddr, NULL, NULL,
+ &fd, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
fd = -1;
}
}