2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

2739. [cleanup] Clean up API for initializing and clearing trust

anchors for a view. [RT #20211]
This commit is contained in:
Evan Hunt
2009-10-27 22:46:13 +00:00
parent 9a97696b54
commit 95f2377b4f
8 changed files with 190 additions and 61 deletions

View File

@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: client.c,v 1.5 2009/09/03 21:45:46 jinmei Exp $ */
/* $Id: client.c,v 1.6 2009/10/27 22:46:13 each Exp $ */
#include <config.h>
@@ -309,16 +309,11 @@ dns_client_createview(isc_mem_t *mctx, dns_rdataclass_t rdclass,
if (result != ISC_R_SUCCESS)
return (result);
/*
* Workaround for a recent change in dns_view_create(): proactively
* create view->secroots if it's not created with view creation.
*/
if (view->secroots == NULL) {
result = dns_keytable_create(mctx, &view->secroots);
if (result != ISC_R_SUCCESS) {
dns_view_detach(&view);
return (result);
}
/* Initialize view security roots */
result = dns_view_initsecroots(view, mctx);
if (result != ISC_R_SUCCESS) {
dns_view_detach(&view);
return (result);
}
result = dns_view_createresolver(view, taskmgr, ntasks, socketmgr,
@@ -1398,6 +1393,7 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass,
isc_result_t result;
dns_view_t *view = NULL;
dst_key_t *dstkey = NULL;
dns_keytable_t *secroots = NULL;
REQUIRE(DNS_CLIENT_VALID(client));
@@ -1406,17 +1402,24 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass,
rdclass, &view);
UNLOCK(&client->lock);
if (result != ISC_R_SUCCESS)
return (result);
goto cleanup;
result = dns_view_getsecroots(view, &secroots);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dst_key_fromdns(keyname, rdclass, keydatabuf, client->mctx,
&dstkey);
if (result != ISC_R_SUCCESS)
return (result);
goto cleanup;
result = dns_keytable_add(view->secroots, ISC_FALSE, &dstkey);
dns_view_detach(&view);
result = dns_keytable_add(secroots, ISC_FALSE, &dstkey);
cleanup:
if (view != NULL)
dns_view_detach(&view);
if (secroots != NULL)
dns_keytable_detach(&secroots);
return (result);
}