2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

configuration failed when trusted-keys statement was missing

This commit is contained in:
Andreas Gustafsson
2000-04-11 17:52:57 +00:00
parent e7a8dfd296
commit 864a05fa26

View File

@@ -206,70 +206,74 @@ configure_view_dnsseckeys(dns_c_ctx_t *cctx,
dns_keytable_t *keytable = NULL; dns_keytable_t *keytable = NULL;
dst_key_t *dstkey = NULL; dst_key_t *dstkey = NULL;
CHECK((*cget)(cctx, &ckeys));
CHECK(dns_keytable_create(mctx, &keytable)); CHECK(dns_keytable_create(mctx, &keytable));
for (ckey = ISC_LIST_HEAD(ckeys->tkeylist); result = (*cget)(cctx, &ckeys);
ckey != NULL; if (result == ISC_R_SUCCESS) {
ckey = ISC_LIST_NEXT(ckey, next)) for (ckey = ISC_LIST_HEAD(ckeys->tkeylist);
{ ckey != NULL;
dns_rdataclass_t viewclass; ckey = ISC_LIST_NEXT(ckey, next))
dns_rdata_generic_key_t keystruct; {
isc_int32_t flags, proto, alg; dns_rdataclass_t viewclass;
unsigned char keydata[4096]; dns_rdata_generic_key_t keystruct;
isc_buffer_t keydatabuf; isc_int32_t flags, proto, alg;
unsigned char rrdata[4096]; unsigned char keydata[4096];
isc_buffer_t rrdatabuf; isc_buffer_t keydatabuf;
isc_region_t r; unsigned char rrdata[4096];
isc_buffer_t rrdatabuf;
isc_region_t r;
if (cview == NULL) if (cview == NULL)
viewclass = dns_rdataclass_in; viewclass = dns_rdataclass_in;
else else
CHECK(dns_c_view_getviewclass(cview, &viewclass)); CHECK(dns_c_view_getviewclass(cview,
keystruct.common.rdclass = viewclass; &viewclass));
keystruct.common.rdtype = dns_rdatatype_key; keystruct.common.rdclass = viewclass;
/* keystruct.common.rdtype = dns_rdatatype_key;
* The key data in keystruct is not really /*
* dynamically allocated, but dns_rdata_fromstruct() * The key data in keystruct is not really
* requires that there is a valid mctx anyway. * dynamically allocated, but dns_rdata_fromstruct()
*/ * requires that there is a valid mctx anyway.
keystruct.mctx = mctx; */
keystruct.mctx = mctx;
ISC_LINK_INIT(&keystruct.common, link); ISC_LINK_INIT(&keystruct.common, link);
flags = ckey->pubkey->flags; flags = ckey->pubkey->flags;
proto = ckey->pubkey->protocol; proto = ckey->pubkey->protocol;
alg = ckey->pubkey->algorithm; alg = ckey->pubkey->algorithm;
if (flags < 0 || flags > 0xffff) if (flags < 0 || flags > 0xffff)
CHECKM(DNS_R_RANGE, "key flags"); CHECKM(DNS_R_RANGE, "key flags");
if (proto < 0 || proto > 0xff) if (proto < 0 || proto > 0xff)
CHECKM(DNS_R_RANGE, "key protocol"); CHECKM(DNS_R_RANGE, "key protocol");
if (alg < 0 || alg > 0xff) if (alg < 0 || alg > 0xff)
CHECKM(DNS_R_RANGE, "key algorithm"); CHECKM(DNS_R_RANGE, "key algorithm");
keystruct.flags = flags; keystruct.flags = flags;
keystruct.protocol = proto; keystruct.protocol = proto;
keystruct.algorithm = alg; keystruct.algorithm = alg;
isc_buffer_init(&keydatabuf, keydata, sizeof(keydata), isc_buffer_init(&keydatabuf, keydata, sizeof(keydata),
ISC_BUFFERTYPE_BINARY); ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata), isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata),
ISC_BUFFERTYPE_BINARY); ISC_BUFFERTYPE_BINARY);
CHECK(base64_cstring_tobuffer(mctx, ckey->pubkey->key, CHECK(base64_cstring_tobuffer(mctx, ckey->pubkey->key,
&keydatabuf)); &keydatabuf));
isc_buffer_used(&keydatabuf, &r); isc_buffer_used(&keydatabuf, &r);
keystruct.datalen = r.length; keystruct.datalen = r.length;
keystruct.data = r.base; keystruct.data = r.base;
CHECK(dns_rdata_fromstruct(NULL, keystruct.common.rdclass, CHECK(dns_rdata_fromstruct(NULL, keystruct.common.rdclass,
keystruct.common.rdtype, keystruct.common.rdtype,
&keystruct, &rrdatabuf)); &keystruct, &rrdatabuf));
CHECK(dst_key_fromdns(ckey->domain, &rrdatabuf, mctx, &dstkey)); CHECK(dst_key_fromdns(ckey->domain, &rrdatabuf, mctx,
&dstkey));
CHECK(dns_keytable_add(keytable, &dstkey)); CHECK(dns_keytable_add(keytable, &dstkey));
INSIST(dstkey == NULL); INSIST(dstkey == NULL);
} }
} else if (result != ISC_R_NOTFOUND)
goto cleanup;
dns_keytable_detach(target); dns_keytable_detach(target);
*target = keytable; /* Transfer ownership. */ *target = keytable; /* Transfer ownership. */