From: Ralph Boehme Date: Thu, 24 Nov 2022 11:15:13 +0000 (+0100) Subject: winbindd: simplify find_new_dc() X-Git-Tag: talloc-2.4.0~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccb6b75482c80572862ca7a189bfe26565f23b45;p=thirdparty%2Fsamba.git winbindd: simplify find_new_dc() Remove the dcname and pss args from find_new_dc(). The caller passes in the domain anyway, so let's fill in domain->dcname and domain->dcaddr directly. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 250465fcdea..73bc441fd59 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1396,15 +1396,13 @@ static bool get_dcs(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain, @param[in] mem_ctx talloc memory context to allocate from @param[in] domain domain to find a dc in - @param[out] dcname NetBIOS or FQDN of DC that's connected to - @param[out] pss DC Internet address and port @param[out] fd fd of the open socket connected to the newly found dc @return true when a DC connection is made, false otherwise *******************************************************************/ static bool find_new_dc(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain, - char **dcname, struct sockaddr_storage *pss, int *fd, + int *fd, uint32_t request_flags) { struct dc_name_ip *dcs = NULL; @@ -1420,6 +1418,7 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx, size_t fd_index; NTSTATUS status; + bool ok; *fd = -1; @@ -1460,20 +1459,27 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx, return False; } - *pss = addrs[fd_index]; + domain->dcaddr = addrs[fd_index]; if (*dcnames[fd_index] != '\0' && !is_ipaddress(dcnames[fd_index])) { /* Ok, we've got a name for the DC */ - *dcname = talloc_strdup(mem_ctx, dcnames[fd_index]); - if (*dcname == NULL) { + TALLOC_FREE(domain->dcname); + domain->dcname = talloc_strdup(mem_ctx, dcnames[fd_index]); + if (domain->dcname == NULL) { return false; } return true; } /* Try to figure out the name */ - if (dcip_check_name(mem_ctx, domain, pss, dcname, request_flags)) { - return True; + TALLOC_FREE(domain->dcname); + ok = dcip_check_name(domain, + domain, + &domain->dcaddr, + &domain->dcname, + request_flags); + if (ok) { + return true; } /* We can not continue without the DC's name */ @@ -1701,15 +1707,6 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain, set_global_winbindd_state_offline(); break; } - if (dcname != NULL) { - talloc_free(domain->dcname); - - domain->dcname = talloc_move(domain, &dcname); - if (domain->dcname == NULL) { - result = NT_STATUS_NO_MEMORY; - break; - } - } new_conn->cli = NULL;