From 133b474c6d8cc0191148f3a00cab878784aaf9bd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Dec 2010 21:55:01 +0100 Subject: [PATCH] s3: Use smbsock_any_connect in winbind The last 8 patches address bug #7881 (winbind flaky against w2k8). (cherry picked from commit 1a929d8f4c6bae302e5cc53d81117a05eae5fede) --- source3/winbindd/winbindd_cm.c | 58 ++++++++-------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 0a5c147fd57..6d99f642e67 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -823,21 +823,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)) { @@ -1340,7 +1325,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; @@ -1358,15 +1346,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)) @@ -1375,14 +1354,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; iname, ab, strerror(errno) )); + domain->name, ab, nt_errstr(status) )); winbind_add_failed_connection_entry(domain, dcs[i].name, NT_STATUS_UNSUCCESSFUL); } @@ -1484,23 +1464,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))) { - 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; } } -- 2.34.1