mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
Add a talloc context to sitename_fetch().
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
parent
6b915bfd0f
commit
32037e0533
@ -414,7 +414,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
|
||||
return NT_STATUS_NO_LOGON_SERVERS;
|
||||
}
|
||||
|
||||
sitename = sitename_fetch(realm);
|
||||
sitename = sitename_fetch(talloc_tos(), realm);
|
||||
|
||||
again:
|
||||
|
||||
@ -429,7 +429,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
|
||||
goto again;
|
||||
}
|
||||
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
|
||||
|
||||
if ( ads_try_connect(ads, server, false) ) {
|
||||
SAFE_FREE(ip_list);
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
|
||||
if (sitename) {
|
||||
DEBUG(1,("ads_find_dc: failed to find a valid DC on our site (%s), "
|
||||
"trying to find another DC\n", sitename));
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
namecache_delete(realm, 0x1C);
|
||||
goto again;
|
||||
}
|
||||
@ -563,9 +563,9 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
|
||||
if (!realm)
|
||||
realm = lp_realm();
|
||||
|
||||
if ((sitename = sitename_fetch(realm)) == NULL) {
|
||||
if ((sitename = sitename_fetch(frame, realm)) == NULL) {
|
||||
ads_lookup_site();
|
||||
sitename = sitename_fetch(realm);
|
||||
sitename = sitename_fetch(frame, realm);
|
||||
}
|
||||
|
||||
dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
|
||||
@ -581,8 +581,6 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
|
||||
realm, sitename,
|
||||
&gcs_list, &num_gcs);
|
||||
|
||||
SAFE_FREE(sitename);
|
||||
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
ads_status = ADS_ERROR_NT(nt_status);
|
||||
goto done;
|
||||
@ -618,7 +616,6 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
|
||||
} while (!done);
|
||||
|
||||
done:
|
||||
SAFE_FREE(sitename);
|
||||
talloc_destroy(frame);
|
||||
|
||||
return ads_status;
|
||||
|
@ -79,7 +79,7 @@ bool sitename_store(const char *realm, const char *sitename)
|
||||
Caller must free.
|
||||
****************************************************************************/
|
||||
|
||||
char *sitename_fetch(const char *realm)
|
||||
char *sitename_fetch(TALLOC_CTX *mem_ctx, const char *realm)
|
||||
{
|
||||
char *sitename = NULL;
|
||||
time_t timeout;
|
||||
@ -95,7 +95,7 @@ char *sitename_fetch(const char *realm)
|
||||
|
||||
key = sitename_key(query_realm);
|
||||
|
||||
ret = gencache_get( key, NULL, &sitename, &timeout );
|
||||
ret = gencache_get( key, mem_ctx, &sitename, &timeout );
|
||||
SAFE_FREE(key);
|
||||
if ( !ret ) {
|
||||
DEBUG(5,("sitename_fetch: No stored sitename for %s\n",
|
||||
@ -122,7 +122,7 @@ bool stored_sitename_changed(const char *realm, const char *sitename)
|
||||
return False;
|
||||
}
|
||||
|
||||
new_sitename = sitename_fetch(realm);
|
||||
new_sitename = sitename_fetch(talloc_tos(), realm);
|
||||
|
||||
if (sitename && new_sitename && !strequal(sitename, new_sitename)) {
|
||||
ret = True;
|
||||
@ -130,7 +130,7 @@ bool stored_sitename_changed(const char *realm, const char *sitename)
|
||||
(!sitename && new_sitename)) {
|
||||
ret = True;
|
||||
}
|
||||
SAFE_FREE(new_sitename);
|
||||
TALLOC_FREE(new_sitename);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define _LIBADS_SITENAME_CACHE_H_
|
||||
|
||||
bool sitename_store(const char *realm, const char *sitename);
|
||||
char *sitename_fetch(const char *realm);
|
||||
char *sitename_fetch(TALLOC_CTX *mem_ctx, const char *realm);
|
||||
bool stored_sitename_changed(const char *realm, const char *sitename);
|
||||
|
||||
#endif /* _LIBADS_SITENAME_CACHE_H_ */
|
||||
|
@ -1185,7 +1185,7 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
|
||||
bool retry_query_with_null = false;
|
||||
|
||||
if ((site_name == NULL) || (site_name[0] == '\0')) {
|
||||
ptr_to_free = sitename_fetch(domain_name);
|
||||
ptr_to_free = sitename_fetch(mem_ctx, domain_name);
|
||||
if (ptr_to_free != NULL) {
|
||||
retry_query_with_null = true;
|
||||
}
|
||||
@ -1202,7 +1202,7 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
|
||||
flags,
|
||||
info);
|
||||
|
||||
SAFE_FREE(ptr_to_free);
|
||||
TALLOC_FREE(ptr_to_free);
|
||||
|
||||
if (!NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
|
||||
return status;
|
||||
|
@ -2799,7 +2799,7 @@ bool resolve_name(const char *name,
|
||||
return interpret_string_addr(return_ss, name, AI_NUMERICHOST);
|
||||
}
|
||||
|
||||
sitename = sitename_fetch(lp_realm()); /* wild guess */
|
||||
sitename = sitename_fetch(talloc_tos(), lp_realm()); /* wild guess */
|
||||
|
||||
status = internal_resolve_name(name, name_type, sitename,
|
||||
&ss_list, &count,
|
||||
@ -2814,7 +2814,7 @@ bool resolve_name(const char *name,
|
||||
(ss_list[i].ss.ss_family == AF_INET)) {
|
||||
*return_ss = ss_list[i].ss;
|
||||
SAFE_FREE(ss_list);
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
@ -2826,14 +2826,14 @@ bool resolve_name(const char *name,
|
||||
!is_broadcast_addr((struct sockaddr *)(void *)&ss_list[i].ss)) {
|
||||
*return_ss = ss_list[i].ss;
|
||||
SAFE_FREE(ss_list);
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_FREE(ss_list);
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -2873,12 +2873,12 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
sitename = sitename_fetch(lp_realm()); /* wild guess */
|
||||
sitename = sitename_fetch(ctx, lp_realm()); /* wild guess */
|
||||
|
||||
status = internal_resolve_name(name, name_type, sitename,
|
||||
&ss_list, &count,
|
||||
lp_name_resolve_order());
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
|
@ -64,13 +64,13 @@ static bool ads_dc_name(const char *domain,
|
||||
realm = lp_realm();
|
||||
}
|
||||
|
||||
sitename = sitename_fetch(realm);
|
||||
sitename = sitename_fetch(talloc_tos(), realm);
|
||||
|
||||
/* Try this 3 times then give up. */
|
||||
for( i =0 ; i < 3; i++) {
|
||||
ads = ads_init(realm, domain, NULL);
|
||||
if (!ads) {
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ static bool ads_dc_name(const char *domain,
|
||||
#endif
|
||||
|
||||
if (!ads->config.realm) {
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
ads_destroy(&ads);
|
||||
return False;
|
||||
}
|
||||
@ -93,8 +93,8 @@ static bool ads_dc_name(const char *domain,
|
||||
to ensure we only find servers in our site. */
|
||||
|
||||
if (stored_sitename_changed(realm, sitename)) {
|
||||
SAFE_FREE(sitename);
|
||||
sitename = sitename_fetch(realm);
|
||||
TALLOC_FREE(sitename);
|
||||
sitename = sitename_fetch(talloc_tos(), realm);
|
||||
ads_destroy(&ads);
|
||||
/* Ensure we don't cache the DC we just connected to. */
|
||||
namecache_delete(realm, 0x1C);
|
||||
@ -129,12 +129,12 @@ static bool ads_dc_name(const char *domain,
|
||||
if (i == 3) {
|
||||
DEBUG(1,("ads_dc_name: sitename (now \"%s\") keeps changing ???\n",
|
||||
sitename ? sitename : ""));
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
ads_destroy(&ads);
|
||||
return False;
|
||||
}
|
||||
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
|
||||
fstrcpy(srv_name, ads->config.ldap_server_name);
|
||||
if (!strupper_m(srv_name)) {
|
||||
|
@ -113,15 +113,14 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
|
||||
else
|
||||
domain = c->opt_target_workgroup;
|
||||
|
||||
sitename = sitename_fetch(domain);
|
||||
|
||||
if ( (ctx = talloc_init("net_lookup_ldap")) == NULL ) {
|
||||
d_fprintf(stderr,"net_lookup_ldap: talloc_init() %s!\n",
|
||||
_("failed"));
|
||||
SAFE_FREE(sitename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sitename = sitename_fetch(ctx, domain);
|
||||
|
||||
DEBUG(9, ("Lookup up ldap for domain %s\n", domain));
|
||||
|
||||
dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
|
||||
@ -130,14 +129,12 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
|
||||
if ( NT_STATUS_IS_OK(status) && numdcs ) {
|
||||
print_ldap_srvlist(dcs, numdcs);
|
||||
TALLOC_FREE( ctx );
|
||||
SAFE_FREE(sitename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG(9, ("Looking up PDC for domain %s\n", domain));
|
||||
if (!get_pdc_ip(domain, &ss)) {
|
||||
TALLOC_FREE( ctx );
|
||||
SAFE_FREE(sitename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -149,7 +146,6 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
|
||||
|
||||
if (ret) {
|
||||
TALLOC_FREE( ctx );
|
||||
SAFE_FREE(sitename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -157,7 +153,6 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
|
||||
domain = strchr(h_name, '.');
|
||||
if (!domain) {
|
||||
TALLOC_FREE( ctx );
|
||||
SAFE_FREE(sitename);
|
||||
return -1;
|
||||
}
|
||||
domain++;
|
||||
@ -169,12 +164,10 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
|
||||
if ( NT_STATUS_IS_OK(status) && numdcs ) {
|
||||
print_ldap_srvlist(dcs, numdcs);
|
||||
TALLOC_FREE( ctx );
|
||||
SAFE_FREE(sitename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TALLOC_FREE( ctx );
|
||||
SAFE_FREE(sitename);
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
@ -212,14 +205,14 @@ static int net_lookup_dc(struct net_context *c, int argc, const char **argv)
|
||||
}
|
||||
d_printf("%s\n", pdc_str);
|
||||
|
||||
sitename = sitename_fetch(domain);
|
||||
sitename = sitename_fetch(talloc_tos(), domain);
|
||||
if (!NT_STATUS_IS_OK(get_sorted_dc_list(domain, sitename,
|
||||
&ip_list, &count, sec_ads))) {
|
||||
SAFE_FREE(pdc_str);
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
return 0;
|
||||
}
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
for (i=0;i<count;i++) {
|
||||
print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
|
||||
if (!strequal(pdc_str, addr))
|
||||
|
@ -1161,7 +1161,7 @@ static bool dcip_to_name(TALLOC_CTX *mem_ctx,
|
||||
|
||||
if (domain->primary && (ads->config.flags & NBT_SERVER_KDC)) {
|
||||
if (ads_closest_dc(ads)) {
|
||||
char *sitename = sitename_fetch(ads->config.realm);
|
||||
char *sitename = sitename_fetch(mem_ctx, ads->config.realm);
|
||||
|
||||
/* We're going to use this KDC for this realm/domain.
|
||||
If we are using sites, then force the krb5 libs
|
||||
@ -1173,7 +1173,7 @@ static bool dcip_to_name(TALLOC_CTX *mem_ctx,
|
||||
pss,
|
||||
*name);
|
||||
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
} else {
|
||||
/* use an off site KDC */
|
||||
create_local_private_krb5_conf_for_domain(domain->alt_name,
|
||||
@ -1279,7 +1279,7 @@ static bool get_dcs(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
|
||||
|
||||
get_dc_name(domain->name, domain->alt_name, dcname, &ss);
|
||||
|
||||
sitename = sitename_fetch(domain->alt_name);
|
||||
sitename = sitename_fetch(mem_ctx, domain->alt_name);
|
||||
if (sitename) {
|
||||
|
||||
/* Do the site-specific AD dns lookup first. */
|
||||
@ -1303,7 +1303,7 @@ static bool get_dcs(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
|
||||
}
|
||||
|
||||
SAFE_FREE(ip_list);
|
||||
SAFE_FREE(sitename);
|
||||
TALLOC_FREE(sitename);
|
||||
iplist_size = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user