From: Volker Lendecke Date: Tue, 21 Dec 2010 20:55:01 +0000 (+0100) Subject: s3: Use smbsock_any_connect in winbind X-Git-Url: http://git.samba.org/?p=obnox%2Fsamba-ctdb.git;a=commitdiff_plain;h=2fc3e7f2ed11b1beee8dab35f05baaa4f2d19ecd s3: Use smbsock_any_connect in winbind --- diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index ece68f1a1d..5a6f9e2f6b 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -803,21 +803,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)) { @@ -1318,7 +1303,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; @@ -1336,15 +1324,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)) @@ -1353,14 +1332,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); } @@ -1462,23 +1442,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; } }