mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Return configured DNSKEYs even though we don't have RRSIGS for them.
This commit is contained in:
@@ -73,8 +73,7 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
|
|||||||
keyblock_free = block->next;
|
keyblock_free = block->next;
|
||||||
blockdata_count++;
|
blockdata_count++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!block)
|
|
||||||
{
|
{
|
||||||
/* failed to alloc, free partial chain */
|
/* failed to alloc, free partial chain */
|
||||||
blockdata_free(ret);
|
blockdata_free(ret);
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
|
|||||||
insert. Once in this state, all inserts will probably fail. */
|
insert. Once in this state, all inserts will probably fail. */
|
||||||
if (free_avail)
|
if (free_avail)
|
||||||
{
|
{
|
||||||
static warned = 0;
|
static int warned = 0;
|
||||||
if (!warned)
|
if (!warned)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_ERR, _("Internal error in cache."));
|
my_syslog(LOG_ERR, _("Internal error in cache."));
|
||||||
|
|||||||
125
src/rfc1035.c
125
src/rfc1035.c
@@ -1553,34 +1553,35 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
if (option_bool(OPT_DNSSEC_VALID) && (qtype == T_DNSKEY || qtype == T_DS || qtype == T_RRSIG))
|
if (option_bool(OPT_DNSSEC_VALID) && (qtype == T_DNSKEY || qtype == T_DS || qtype == T_RRSIG))
|
||||||
{
|
{
|
||||||
int gotone = 0;
|
int gotone = 0, have_rrsig = 0;
|
||||||
struct blockdata *keydata;
|
struct blockdata *keydata;
|
||||||
|
|
||||||
/* Do we have RRSIG? Can't do DS or DNSKEY otherwise. */
|
/* Do we have RRSIG? Can't do DS or DNSKEY otherwise. */
|
||||||
crecp = NULL;
|
crecp = NULL;
|
||||||
while ((crecp = cache_find_by_name(crecp, name, now, F_DNSKEY | F_DS)))
|
while ((crecp = cache_find_by_name(crecp, name, now, F_DNSKEY | F_DS)))
|
||||||
if (crecp->uid == qclass && (qtype == T_RRSIG || crecp->addr.sig.type_covered == qtype))
|
if (crecp->uid == qclass && (qtype == T_RRSIG || crecp->addr.sig.type_covered == qtype))
|
||||||
break;
|
{
|
||||||
|
have_rrsig = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (crecp)
|
if (qtype == T_RRSIG && have_rrsig)
|
||||||
{
|
{
|
||||||
if (qtype == T_RRSIG)
|
ans = gotone = 1;
|
||||||
{
|
auth = 0;
|
||||||
ans = gotone = 1;
|
}
|
||||||
auth = 0;
|
else if (qtype == T_DS && have_rrsig)
|
||||||
}
|
{
|
||||||
else if (qtype == T_DS)
|
auth = 0;
|
||||||
{
|
crecp = NULL;
|
||||||
auth = 0;
|
while ((crecp = cache_find_by_name(crecp, name, now, F_DS)))
|
||||||
crecp = NULL;
|
if (crecp->uid == qclass)
|
||||||
while ((crecp = cache_find_by_name(crecp, name, now, F_DS)))
|
{
|
||||||
if (crecp->uid == qclass)
|
ans = gotone = 1;
|
||||||
|
if (!dryrun && (keydata = blockdata_retrieve(crecp->addr.ds.keydata, crecp->addr.ds.keylen, NULL)))
|
||||||
{
|
{
|
||||||
ans = gotone = 1;
|
struct all_addr a;
|
||||||
if (!dryrun && (keydata = blockdata_retrieve(crecp->addr.ds.keydata, crecp->addr.ds.keylen, NULL)))
|
a.addr.keytag = crecp->addr.ds.keytag;
|
||||||
{
|
|
||||||
struct all_addr a;
|
|
||||||
a.addr.keytag = crecp->addr.ds.keytag;
|
|
||||||
log_query(F_KEYTAG | (crecp->flags & F_CONFIG), name, &a, "DS keytag %u");
|
log_query(F_KEYTAG | (crecp->flags & F_CONFIG), name, &a, "DS keytag %u");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
crec_ttl(crecp, now), &nameoffset,
|
crec_ttl(crecp, now), &nameoffset,
|
||||||
@@ -1588,54 +1589,56 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
crecp->addr.ds.keytag, crecp->addr.ds.algo, crecp->addr.ds.digest, crecp->addr.ds.keylen, keydata))
|
crecp->addr.ds.keytag, crecp->addr.ds.algo, crecp->addr.ds.digest, crecp->addr.ds.keylen, keydata))
|
||||||
anscount++;
|
anscount++;
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (qtype == T_DNSKEY)
|
|
||||||
{
|
|
||||||
crecp = NULL;
|
|
||||||
while ((crecp = cache_find_by_name(crecp, name, now, F_DNSKEY)))
|
|
||||||
if (crecp->uid == qclass)
|
|
||||||
{
|
|
||||||
if (!(crecp->flags & F_CONFIG))
|
|
||||||
auth = 0;
|
|
||||||
ans = gotone = 1;
|
|
||||||
if (!dryrun && (keydata = blockdata_retrieve(crecp->addr.key.keydata, crecp->addr.key.keylen, NULL)))
|
|
||||||
{
|
|
||||||
struct all_addr a;
|
|
||||||
a.addr.keytag = crecp->addr.key.keytag;
|
|
||||||
log_query(F_KEYTAG | (crecp->flags & F_CONFIG), name, &a, "DNSKEY keytag %u");
|
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
|
||||||
crec_ttl(crecp, now), &nameoffset,
|
|
||||||
T_DNSKEY, qclass, "sbbt",
|
|
||||||
crecp->addr.key.flags, 3, crecp->addr.key.algo, crecp->addr.key.keylen, keydata))
|
|
||||||
anscount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Now do RRSIGs */
|
else if (qtype == T_DNSKEY)
|
||||||
if (gotone)
|
{
|
||||||
{
|
crecp = NULL;
|
||||||
crecp = NULL;
|
while ((crecp = cache_find_by_name(crecp, name, now, F_DNSKEY)))
|
||||||
while ((crecp = cache_find_by_name(crecp, name, now, F_DNSKEY | F_DS)))
|
if (crecp->uid == qclass)
|
||||||
if (crecp->uid == qclass && (qtype == T_RRSIG || (sec_reqd && crecp->addr.sig.type_covered == qtype)) &&
|
{
|
||||||
!dryrun &&
|
if ((crecp->flags & F_CONFIG) || have_rrsig) /* Return configured keys without an RRISG */
|
||||||
(keydata = blockdata_retrieve(crecp->addr.sig.keydata, crecp->addr.sig.keylen, NULL)))
|
|
||||||
{
|
{
|
||||||
if (qtype == T_RRSIG)
|
if (!(crecp->flags & F_CONFIG))
|
||||||
|
auth = 0, gotone = 1;
|
||||||
|
ans = 1;
|
||||||
|
if (!dryrun && (keydata = blockdata_retrieve(crecp->addr.key.keydata, crecp->addr.key.keylen, NULL)))
|
||||||
{
|
{
|
||||||
char types[20];
|
struct all_addr a;
|
||||||
querystr("rrsig", types, crecp->addr.sig.type_covered);
|
a.addr.keytag = crecp->addr.key.keytag;
|
||||||
log_query(F_RRNAME, name, NULL, types);
|
log_query(F_KEYTAG | (crecp->flags & F_CONFIG), name, &a, "DNSKEY keytag %u");
|
||||||
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
crec_ttl(crecp, now), &nameoffset,
|
||||||
|
T_DNSKEY, qclass, "sbbt",
|
||||||
|
crecp->addr.key.flags, 3, crecp->addr.key.algo, crecp->addr.key.keylen, keydata))
|
||||||
|
anscount++;
|
||||||
}
|
}
|
||||||
if ((keydata = blockdata_retrieve(crecp->addr.sig.keydata, crecp->addr.sig.keylen, NULL)) &&
|
|
||||||
add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
|
||||||
crec_ttl(crecp, now), &nameoffset,
|
|
||||||
T_RRSIG, qclass, "t", crecp->addr.sig.keylen, keydata))
|
|
||||||
anscount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now do RRSIGs */
|
||||||
|
if (gotone)
|
||||||
|
{
|
||||||
|
crecp = NULL;
|
||||||
|
while ((crecp = cache_find_by_name(crecp, name, now, F_DNSKEY | F_DS)))
|
||||||
|
if (crecp->uid == qclass && (qtype == T_RRSIG || (sec_reqd && crecp->addr.sig.type_covered == qtype)) &&
|
||||||
|
!dryrun &&
|
||||||
|
(keydata = blockdata_retrieve(crecp->addr.sig.keydata, crecp->addr.sig.keylen, NULL)))
|
||||||
|
{
|
||||||
|
if (qtype == T_RRSIG)
|
||||||
|
{
|
||||||
|
char types[20];
|
||||||
|
querystr("rrsig", types, crecp->addr.sig.type_covered);
|
||||||
|
log_query(F_RRNAME, name, NULL, types);
|
||||||
|
}
|
||||||
|
if ((keydata = blockdata_retrieve(crecp->addr.sig.keydata, crecp->addr.sig.keylen, NULL)) &&
|
||||||
|
add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
crec_ttl(crecp, now), &nameoffset,
|
||||||
|
T_RRSIG, qclass, "t", crecp->addr.sig.keylen, keydata))
|
||||||
|
anscount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user