summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-09-04 13:39:31 -0700
committerJeremy Allison <jra@samba.org>2013-09-05 09:17:13 -0700
commit6b915bfd0f4194453c1b01158f2c2772b2a2df2f (patch)
treec1fcb0b1b0ff7abba4d2e27b7b853ce9b6926ed3 /source3
parent8a7246ac2c5b27cc29e6ca23c1e2e0f43e298eb5 (diff)
downloadsamba-6b915bfd0f4194453c1b01158f2c2772b2a2df2f.tar.gz
samba-6b915bfd0f4194453c1b01158f2c2772b2a2df2f.tar.bz2
samba-6b915bfd0f4194453c1b01158f2c2772b2a2df2f.zip
Add a talloc context to saf_fetch().
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/libsmb/namequery.c10
-rw-r--r--source3/winbindd/winbindd_ads.c4
-rw-r--r--source3/winbindd/winbindd_cm.c12
4 files changed, 15 insertions, 13 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 811fe4fd91..df65711d65 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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,
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 15c7cacae5..7fac0c97f8 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -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;
diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c
index 4c2638900f..18749c97c4 100644
--- a/source3/winbindd/winbindd_ads.c
+++ b/source3/winbindd/winbindd_ads.c
@@ -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;
}
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 0b8308a5e3..bf0e70d20b 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -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++) {