main/gdnsd: upgrade to 1.11.0

This commit is contained in:
Timo Teräs 2013-12-11 15:08:56 +02:00
parent 4851a3aad3
commit d1f643c0db
3 changed files with 10 additions and 279 deletions

View File

@ -1,265 +0,0 @@
From 22b0dcf8a19aaeb1e6f32ad9f0aad95ab26b8a61 Mon Sep 17 00:00:00 2001
From: Brandon Black <blblack@gmail.com>
Date: Thu, 11 Jul 2013 14:37:57 -0500
Subject: [PATCH] Fix auth section of ANY-query on CNAME
Queries with QTYPE=ANY for a name which has a CNAME RR
should be treated as if QTYPE=CNAME. Prior to this
fix, they were being treated more like QTYPE=A. Given
it's QTYPE=ANY and the effects seem to be limited to
the auth section, I doubt this is a production concern
for anyone, but it's good to be correct.
Fixes Issue #51 (thanks Timo!)
---
gdnsd/dnspacket.c | 11 ++-
t/012cname/001cname.t | 157 +++++++++++++++++++++++++++++++++++++++++++
t/012cname/gdnsd.conf | 11 +++
t/012cname/zones/example.com | 24 +++++++
4 files changed, 201 insertions(+), 2 deletions(-)
create mode 100644 t/012cname/001cname.t
create mode 100644 t/012cname/gdnsd.conf
create mode 100644 t/012cname/zones/example.com
diff --git a/gdnsd/dnspacket.c b/gdnsd/dnspacket.c
index 3c26d83..db7e26a 100644
--- a/gdnsd/dnspacket.c
+++ b/gdnsd/dnspacket.c
@@ -1190,6 +1190,9 @@ static unsigned int encode_rrs_any(dnspacket_context_t* c, unsigned int offset,
case DNS_TYPE_SOA:
offset = encode_rr_soa(c, offset, (const void*)rrset, true);
break;
+ case DNS_TYPE_CNAME:
+ offset = encode_rr_cname(c, offset, (const void*)rrset, true);
+ break;
case DNS_TYPE_NS:
offset = encode_rrs_ns(c, offset, (const void*)rrset, true);
break;
@@ -1659,8 +1662,12 @@ static unsigned int answer_from_db(dnspacket_context_t* c, const uint8_t* qname,
// for the normal response handling code below. The explicit check of the first
// rrsets entry works because if CNAME exists at all, by definition it is the only
// type of rrset at this node.
- while(resdom && resdom->rrsets
- && resdom->rrsets->gen.type == DNS_TYPE_CNAME && c->qtype != DNS_TYPE_CNAME) {
+ while(resdom
+ && resdom->rrsets
+ && resdom->rrsets->gen.type == DNS_TYPE_CNAME
+ && c->qtype != DNS_TYPE_CNAME
+ && c->qtype != DNS_TYPE_ANY) {
+
dmn_assert(status == DNAME_AUTH);
res_hdr->flags1 |= 4; // AA bit
diff --git a/t/012cname/001cname.t b/t/012cname/001cname.t
new file mode 100644
index 0000000..6e96335
--- /dev/null
+++ b/t/012cname/001cname.t
@@ -0,0 +1,157 @@
+
+# CNAME test, with include_optional_ns to get the auth section right...
+# this is basically going through A, CNAME, and ANY queries against
+# five different classes of CNAME targets (local nonexistent,
+# local existent, delegation, delegation glue record, and external).
+# CNAME and ANY responses should be identical (this was the bug that
+# triggered writing these testcases - ANY was being treated more like A).
+
+use _GDT ();
+use FindBin ();
+use File::Spec ();
+use Test::More tests => 17;
+
+my $standard_soa = 'example.com 21600 SOA ns1.example.com hmaster.example.net 1 7200 1800 259200 900';
+
+my $pid = _GDT->test_spawn_daemon(File::Spec->catfile($FindBin::Bin, 'gdnsd.conf'));
+
+_GDT->test_dns(
+ qname => 'cn-nx.example.com', qtype => 'A',
+ header => { rcode => 'NXDOMAIN' },
+ answer => 'cn-nx.example.com 21600 CNAME nx.example.com',
+ auth => $standard_soa,
+ stats => [qw/udp_reqs nxdomain/],
+);
+
+foreach my $qt (qw/CNAME ANY/) {
+ _GDT->test_dns(
+ qname => 'cn-nx.example.com', qtype => $qt,
+ answer => 'cn-nx.example.com 21600 CNAME nx.example.com',
+ auth => [
+ 'example.com 21600 NS ns1.example.com',
+ 'example.com 21600 NS ns2.example.com',
+ ],
+ addtl => [
+ 'ns1.example.com 21600 A 192.0.2.1',
+ 'ns2.example.com 21600 A 192.0.2.2',
+ ],
+ );
+}
+
+_GDT->test_dns(
+ qname => 'cn-local.example.com', qtype => 'A',
+ answer => [
+ 'cn-local.example.com 21600 CNAME ns1.example.com',
+ 'ns1.example.com 21600 A 192.0.2.1',
+ ],
+ auth => [
+ 'example.com 21600 NS ns1.example.com',
+ 'example.com 21600 NS ns2.example.com',
+ ],
+ addtl => [
+ 'ns2.example.com 21600 A 192.0.2.2',
+ ],
+);
+
+foreach my $qt (qw/CNAME ANY/) {
+ _GDT->test_dns(
+ qname => 'cn-local.example.com', qtype => $qt,
+ answer => [
+ 'cn-local.example.com 21600 CNAME ns1.example.com'
+ ],
+ auth => [
+ 'example.com 21600 NS ns1.example.com',
+ 'example.com 21600 NS ns2.example.com',
+ ],
+ addtl => [
+ 'ns1.example.com 21600 A 192.0.2.1',
+ 'ns2.example.com 21600 A 192.0.2.2',
+ ],
+ );
+}
+
+_GDT->test_dns(
+ qname => 'cn-deleg.example.com', qtype => 'A',
+ answer => [
+ 'cn-deleg.example.com 21600 CNAME foo.subz.example.com',
+ ],
+ auth => [
+ 'subz.example.com 21600 NS ns1.subz.example.com',
+ 'subz.example.com 21600 NS ns2.subz.example.com',
+ ],
+ addtl => [
+ 'ns1.subz.example.com 21600 A 192.0.2.10',
+ 'ns2.subz.example.com 21600 A 192.0.2.20',
+ ],
+);
+
+foreach my $qt (qw/CNAME ANY/) {
+ _GDT->test_dns(
+ qname => 'cn-deleg.example.com', qtype => $qt,
+ answer => [
+ 'cn-deleg.example.com 21600 CNAME foo.subz.example.com',
+ ],
+ auth => [
+ 'example.com 21600 NS ns1.example.com',
+ 'example.com 21600 NS ns2.example.com',
+ ],
+ addtl => [
+ 'ns1.example.com 21600 A 192.0.2.1',
+ 'ns2.example.com 21600 A 192.0.2.2',
+ ],
+ );
+}
+
+_GDT->test_dns(
+ qname => 'cn-deleg-glue.example.com', qtype => 'A',
+ answer => [
+ 'cn-deleg-glue.example.com 21600 CNAME ns1.subz.example.com',
+ ],
+ auth => [
+ 'subz.example.com 21600 NS ns1.subz.example.com',
+ 'subz.example.com 21600 NS ns2.subz.example.com',
+ ],
+ addtl => [
+ 'ns1.subz.example.com 21600 A 192.0.2.10',
+ 'ns2.subz.example.com 21600 A 192.0.2.20',
+ ],
+);
+
+foreach my $qt (qw/CNAME ANY/) {
+ _GDT->test_dns(
+ qname => 'cn-deleg-glue.example.com', qtype => $qt,
+ answer => [
+ 'cn-deleg-glue.example.com 21600 CNAME ns1.subz.example.com',
+ ],
+ auth => [
+ 'example.com 21600 NS ns1.example.com',
+ 'example.com 21600 NS ns2.example.com',
+ ],
+ addtl => [
+ 'ns1.example.com 21600 A 192.0.2.1',
+ 'ns2.example.com 21600 A 192.0.2.2',
+ ],
+ );
+}
+
+_GDT->test_dns(
+ qname => 'cn-ext.example.com', qtype => 'A',
+ answer => 'cn-ext.example.com 21600 CNAME www.example.net',
+);
+
+foreach my $qt (qw/CNAME ANY/) {
+ _GDT->test_dns(
+ qname => 'cn-ext.example.com', qtype => $qt,
+ answer => 'cn-ext.example.com 21600 CNAME www.example.net',
+ auth => [
+ 'example.com 21600 NS ns1.example.com',
+ 'example.com 21600 NS ns2.example.com',
+ ],
+ addtl => [
+ 'ns1.example.com 21600 A 192.0.2.1',
+ 'ns2.example.com 21600 A 192.0.2.2',
+ ],
+ );
+}
+
+_GDT->test_kill_daemon($pid);
diff --git a/t/012cname/gdnsd.conf b/t/012cname/gdnsd.conf
new file mode 100644
index 0000000..2bc6c92
--- /dev/null
+++ b/t/012cname/gdnsd.conf
@@ -0,0 +1,11 @@
+options => {
+ listen => @dns_lspec@
+ http_listen => @http_lspec@
+ dns_port => @dns_port@
+ http_port => @http_port@
+ zones_default_ttl = 21600
+ realtime_stats = true
+ max_response = 62464
+ chaos_response = "some random string"
+ include_optional_ns = true
+}
diff --git a/t/012cname/zones/example.com b/t/012cname/zones/example.com
new file mode 100644
index 0000000..94a452f
--- /dev/null
+++ b/t/012cname/zones/example.com
@@ -0,0 +1,24 @@
+
+@ SOA ns1 hmaster.example.net. (
+ 1 ; serial
+ 7200 ; refresh
+ 1800 ; retry
+ 259200 ; expire
+ 900 ; ncache
+)
+
+@ NS ns1
+@ NS ns2
+ns1 A 192.0.2.1
+ns2 A 192.0.2.2
+
+subz NS ns1.subz
+subz NS ns2.subz
+ns1.subz A 192.0.2.10
+ns2.subz A 192.0.2.20
+
+cn-nx CNAME nx
+cn-local CNAME ns1
+cn-deleg CNAME foo.subz
+cn-deleg-glue CNAME ns1.subz
+cn-ext CNAME www.example.net.
--
1.8.3.2

View File

@ -46,8 +46,8 @@ index a57a3d4..a42309d 100644
# How to build gdnsd
sbin_PROGRAMS = gdnsd
-gdnsd_SOURCES = main.c conf.c zsrc_djb.c zsrc_djb.h zsrc_rfc1035.c zsrc_rfc1035.h ztree.c ztree.h zscan_rfc1035.c ltarena.c ltree.c dnspacket.c dnsio_udp.c dnsio_tcp.c statio.c monio.c conf.h dnsio_tcp.h dnsio_udp.h dnspacket.h dnswire.h ltarena.h ltree.h statio.h monio.h zscan_rfc1035.h
+gdnsd_SOURCES = main.c conf.c zsrc_djb.c zsrc_djb.h zscan_djb.c zsrc_rfc1035.c zsrc_rfc1035.h ztree.c ztree.h zscan_rfc1035.c ltarena.c ltree.c dnspacket.c dnsio_udp.c dnsio_tcp.c statio.c monio.c conf.h dnsio_tcp.h dnsio_udp.h dnspacket.h dnswire.h ltarena.h ltree.h statio.h monio.h zscan_rfc1035.h
-gdnsd_SOURCES = main.c conf.c zsrc_djb.c zsrc_djb.h zsrc_rfc1035.c zsrc_rfc1035.h ztree.c ztree.h zscan_rfc1035.c ltarena.c ltree.c dnspacket.c dnsio_udp.c dnsio_tcp.c dnsio.c statio.c monio.c conf.h dnsio_tcp.h dnsio_udp.h dnsio.h dnspacket.h dnswire.h ltarena.h ltree.h statio.h monio.h zscan_rfc1035.h
+gdnsd_SOURCES = main.c conf.c zsrc_djb.c zsrc_djb.h zscan_djb.c zsrc_rfc1035.c zsrc_rfc1035.h ztree.c ztree.h zscan_rfc1035.c ltarena.c ltree.c dnspacket.c dnsio_udp.c dnsio_tcp.c dnsio.c statio.c monio.c conf.h dnsio_tcp.h dnsio_udp.h dnsio.h dnspacket.h dnswire.h ltarena.h ltree.h statio.h monio.h zscan_rfc1035.h
gdnsd_LDADD = libgdnsd/libgdnsd.la $(LIBGDNSD_LIBS) $(CAPLIBS)
zscan_rfc1035.c: zscan_rfc1035.rl

View File

@ -1,8 +1,8 @@
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=gdnsd
pkgver=1.9.0
pkgrel=2
pkgver=1.11.0
pkgrel=0
pkgdesc="Geographic Authoritative DNS server"
url="https://github.com/blblack/gdnsd/"
arch="all"
@ -13,7 +13,6 @@ makedepends="userspace-rcu-dev libev-dev libcap-dev ragel autoconf automake libt
install="$pkgname.pre-install"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/blblack/gdnsd/archive/v$pkgver.tar.gz
0001-Fix-auth-section-of-ANY-query-on-CNAME.patch
0001-Fix-ztree_txn_-API-to-work.patch
0002-Impelement-loading-of-DJBDNS-zone-files.patch
gdnsd.initd"
@ -54,18 +53,15 @@ package() {
"$pkgdir"/etc/init.d/gdnsd || return 1
}
md5sums="17b5450d6b78f73bb3f47f7b2d1e5f0f v1.9.0.tar.gz
c6229e37f4d3f9c2bec7f8e56ef93b0c 0001-Fix-auth-section-of-ANY-query-on-CNAME.patch
md5sums="00144b6b0c5528841216fed5a69246df v1.11.0.tar.gz
64b0232acbd664db83ff2ac800cb5459 0001-Fix-ztree_txn_-API-to-work.patch
bc54485f31d09b0c83eb78dee4cd7446 0002-Impelement-loading-of-DJBDNS-zone-files.patch
87aaa21fb7c4f1b84f27e120db39b722 0002-Impelement-loading-of-DJBDNS-zone-files.patch
85f07d47b324a8913cb87a45067d4f44 gdnsd.initd"
sha256sums="955970ddd07c9926450a07877f106124a57dd56913f40e8fe2262287a2377db0 v1.9.0.tar.gz
459b8fab55c701ffa196e6838056322c60129ab3646eefac4dd4900df8300e2a 0001-Fix-auth-section-of-ANY-query-on-CNAME.patch
sha256sums="c7ca5902d7ebf2bbb0f49e9993916841a5e05b32a9d82f7f693982f207a07dcb v1.11.0.tar.gz
f42d30f3aa88d5fedcf1642de33132beafade609c041ed9f5943ba3da9d7c2fb 0001-Fix-ztree_txn_-API-to-work.patch
f78f0071812ef675e7b57cfa8d0edfcd00be84f6e320afedcf9352bc3a08a197 0002-Impelement-loading-of-DJBDNS-zone-files.patch
445fc93fdacf8f320b1a3bf21c9458df1426437fae588e4f53ae808a35f719ac 0002-Impelement-loading-of-DJBDNS-zone-files.patch
dd1ee7fa4063455f127c444b467625fd12cc51349858757614607cf367804a74 gdnsd.initd"
sha512sums="666cb34241fa3dd345d6dbde6d9166c691e8418eaf913dd2b1a7d1c3aa6b1a6f8d7d74b6f6e7804a989951b45d10e69f34bce647737b8460c5b0fc18e25150aa v1.9.0.tar.gz
703ef89071a21db03f14efa1fc0d269fbd1d50cc6861cd9912cad1076d0cfe91e7cfc4760a6355cca91df1d58387431c3f53ffa8b19342bde54bc850ff80b278 0001-Fix-auth-section-of-ANY-query-on-CNAME.patch
sha512sums="c5c2926480ebc6c8d02fa037367ccf68fec0b6f3c138211511035080deb032f3bafaf4296095a6734a09e9f794e3a0451ee12e31b7142d91d1d71eda61a550ee v1.11.0.tar.gz
c8a1a23a623dcacf3cd799929a974edbe29e0ab36ef85ada4047dd04726c96ff040eff733509f523b9982aa8956408b9a654f8c6c6c26e454773b3b81d4f49cb 0001-Fix-ztree_txn_-API-to-work.patch
c32e7bfd09006344cc53b32fe8597c5d9744d2d66723e0eea6ba4a5ec4db39c5700c844d880bacd41862126a21cdaaca276b8510a512e7f1b5ccdcfdb5ab1f1b 0002-Impelement-loading-of-DJBDNS-zone-files.patch
338ccd7ae56cd099d38c63db98a11ae05c2750ce795d2513a04ebbdbb6dda89e123bde0844b52adef5de4ec99ebf7c2ab77f4672b99a3b00398b45df1d601215 0002-Impelement-loading-of-DJBDNS-zone-files.patch
0e8263182bbfa52aa8176443373d5de8b05dfb3f6d4f3268e0deecaca24832125bb3fa59309a4880bd7ae76ffb612ecb61f6cf00732f0237a4de21fadae219b5 gdnsd.initd"