1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Add a talloc context to saf_fetch().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
Jeremy Allison 2013-09-04 13:39:31 -07:00
parent 8a7246ac2c
commit 6b915bfd0f
4 changed files with 15 additions and 13 deletions

View File

@ -825,7 +825,7 @@ bool namecache_status_fetch(const char *keyname,
bool saf_store( const char *domain, const char *servername );
bool saf_join_store( const char *domain, const char *servername );
bool saf_delete( const char *domain );
char *saf_fetch( const char *domain );
char *saf_fetch(TALLOC_CTX *mem_ctx, const char *domain );
struct tevent_req *node_status_query_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct nmb_name *name,

View File

@ -165,7 +165,7 @@ bool saf_delete( const char *domain )
/****************************************************************************
****************************************************************************/
char *saf_fetch( const char *domain )
char *saf_fetch(TALLOC_CTX *mem_ctx, const char *domain )
{
char *server = NULL;
time_t timeout;
@ -183,7 +183,7 @@ char *saf_fetch( const char *domain )
return NULL;
}
ret = gencache_get( key, NULL, &server, &timeout );
ret = gencache_get( key, mem_ctx, &server, &timeout );
TALLOC_FREE( key );
@ -199,7 +199,7 @@ char *saf_fetch( const char *domain )
return NULL;
}
ret = gencache_get( key, NULL, &server, &timeout );
ret = gencache_get( key, mem_ctx, &server, &timeout );
TALLOC_FREE( key );
@ -3073,7 +3073,7 @@ static NTSTATUS get_dc_list(const char *domain,
/* fetch the server we have affinity for. Add the
'password server' list to a search for our domain controllers */
saf_servername = saf_fetch( domain);
saf_servername = saf_fetch(ctx, domain);
if (strequal(domain, lp_workgroup()) || strequal(domain, lp_realm())) {
pserver = talloc_asprintf(ctx, "%s, %s",
@ -3084,7 +3084,7 @@ static NTSTATUS get_dc_list(const char *domain,
saf_servername ? saf_servername : "");
}
SAFE_FREE(saf_servername);
TALLOC_FREE(saf_servername);
if (!pserver) {
status = NT_STATUS_NO_MEMORY;
goto out;

View File

@ -151,7 +151,7 @@ ADS_STATUS ads_idmap_cached_connection(ADS_STRUCT **adsp, const char *dom_name)
* Check if we can get server nam and realm from SAF cache
* and the domain list.
*/
ldap_server = saf_fetch(dom_name);
ldap_server = saf_fetch(talloc_tos(), dom_name);
DEBUG(10, ("ldap_server from saf cache: '%s'\n",
ldap_server ? ldap_server : ""));
@ -165,6 +165,7 @@ ADS_STATUS ads_idmap_cached_connection(ADS_STRUCT **adsp, const char *dom_name)
" domain '%s'\n", wb_dom->alt_name, dom_name));
if (!get_trust_pw_clear(dom_name, &password, NULL, NULL)) {
TALLOC_FREE(ldap_server);
return ADS_ERROR_NT(NT_STATUS_CANT_ACCESS_DOMAIN_INFO);
}
@ -190,6 +191,7 @@ ADS_STATUS ads_idmap_cached_connection(ADS_STRUCT **adsp, const char *dom_name)
status = ads_cached_connection_connect(adsp, realm, dom_name, ldap_server,
password, realm, 0);
SAFE_FREE(realm);
TALLOC_FREE(ldap_server);
return status;
}

View File

@ -1549,15 +1549,16 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
{
TALLOC_CTX *mem_ctx;
NTSTATUS result;
char *saf_servername = saf_fetch( domain->name );
char *saf_servername;
int retries;
if ((mem_ctx = talloc_init("cm_open_connection")) == NULL) {
SAFE_FREE(saf_servername);
set_domain_offline(domain);
return NT_STATUS_NO_MEMORY;
}
saf_servername = saf_fetch(mem_ctx, domain->name );
/* we have to check the server affinity cache here since
later we select a DC based on response time and not preference */
@ -1577,13 +1578,14 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
if (!interpret_string_addr(&ss, saf_servername,
AI_NUMERICHOST)) {
TALLOC_FREE(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
if (dcip_to_name(mem_ctx, domain, &ss, &dcname)) {
domain->dcname = talloc_strdup(domain,
dcname);
if (domain->dcname == NULL) {
SAFE_FREE(saf_servername);
TALLOC_FREE(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
} else {
@ -1594,12 +1596,10 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
} else {
domain->dcname = talloc_strdup(domain, saf_servername);
if (domain->dcname == NULL) {
SAFE_FREE(saf_servername);
TALLOC_FREE(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
}
SAFE_FREE( saf_servername );
}
for (retries = 0; retries < 3; retries++) {