diff options
-rw-r--r-- | source3/winbindd/winbindd_cm.c | 58 |
1 files 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; 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); } @@ -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; } } |