diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..fea6da7 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,53 @@ +name: Github Autobuild +on: [ push, pull_request ] +jobs: + doIt: + name: Build and run tests + runs-on: ubuntu-latest + steps: + - name: Prepare environment + run: | + sudo apt-get install -y cpanminus libcrypt-openssl-rsa-perl ucspi-tcp + sudo cpanm -i Digest::SHA1 + - name: Check out sources + uses: actions/checkout@v2 + - name: Make tinydnssec + run: | + make + - name: Download djbdns and dependencies + run: | + curl -sSO http://cr.yp.to/djbdns/djbdns-1.05.tar.gz + curl -sSO http://www.fefe.de/dns/djbdns-1.05-test28.diff.xz + curl -sSO http://www.tinydnssec.org/djbdns-ipv6-make.patch + - name: Unpack and patch sources + run: | + mkdir -p _build + cd _build + tar xfz ../djbdns-1.05.tar.gz + cd djbdns-1.05 + tar xfj ../../tinydnssec.tar.bz2 + xzcat ../../djbdns-1.05-test28.diff.xz | patch -p1 + patch -p0 <../../djbdns-ipv6-make.patch + patch -p1 <../../djbdns-1.05-dnssec.patch + - name: Configure + run: | + cd _build/djbdns-1.05 + echo cc --include /usr/include/errno.h >conf-cc + - name: Build + run: | + cd _build/djbdns-1.05 + make + - name: Run unit-tests + run: | + cd _build/djbdns-1.05 + ./run-tests.sh + - name: Run UDP tests + run: | + cd _build/djbdns-1.05 + sudo IP=127.0.0.3 ROOT="`pwd`" UID=1 GID=1 ./tinydns & + SERVER=127.0.0.3 ./run-tests.sh -u + - name: Run TCP tests + run: | + cd _build/djbdns-1.05 + sudo ROOT="`pwd`" UID=1 GID=1 tcpserver -HRl localhost 127.0.0.3 53 ./axfrdns & + SERVER=127.0.0.3 ./run-tests.sh -t diff --git a/INSTALL.tinydnssec b/INSTALL.tinydnssec index b9784a7..65b3c0a 100644 --- a/INSTALL.tinydnssec +++ b/INSTALL.tinydnssec @@ -11,7 +11,8 @@ to install before the tinydnssec patch applies: Unfortunately, fefe refuses to name a license for this patch, which means that I cannot redistribute it. -2. My own fixes to the Makefile (IPv6-related): djbdns-ipv6-make.patch +2. My own fixes to the Makefile (IPv6-related): + http://www.tinydnssec.org/djbdns-ipv6-make.patch Build ----- @@ -19,7 +20,7 @@ Build 1. Download and unpack the original djbdns sources from http://cr.yp.to/djbdns/install.html . 2. Download and apply the patches listed above. -3. Download and unpack http://tinydnssec.org/tinydnssec-1.05-1.5.tar.bz2 in +3. Download and unpack http://tinydnssec.org/tinydnssec-1.05-1.7.tar.bz2 in the top-level source directory. 4. Apply djbdns-1.05-dnssec.patch. 5. Install as per usual instructions (see http://cr.yp.to/djbdns/install.html ). diff --git a/README.tinydnssec b/README.tinydnssec index b68a6c8..94b906c 100644 --- a/README.tinydnssec +++ b/README.tinydnssec @@ -109,7 +109,7 @@ update: LICENSE ------- -(C) 2012,2015,2017,2019 Peter Conrad +(C) 2012,2015,2017,2019,2020 Peter Conrad This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as diff --git a/djbdns-1.05-dnssec.patch b/djbdns-1.05-dnssec.patch index 99a55e4..f2a53a1 100644 --- a/djbdns-1.05-dnssec.patch +++ b/djbdns-1.05-dnssec.patch @@ -1,4 +1,4 @@ -(C) 2012 Peter Conrad +(C) 2012,2019,2020 Peter Conrad This patch is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -1223,8 +1223,8 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS +base32hex.o +printtype.o +edns0.o ---- djbdns-1.05-ipv6/tdlookup.c 2019-07-22 14:04:16.803064553 +0200 -+++ djbdns-1.05-dnssec/tdlookup.c 2019-07-22 20:36:57.566950278 +0200 +--- djbdns-1.05.orig/tdlookup.c 2020-05-31 12:26:32.153583322 +0200 ++++ djbdns-1.05/tdlookup.c 2020-05-31 11:59:14.367285275 +0200 @@ -10,6 +10,9 @@ #include "response.h" #include "ip6.h" @@ -1253,7 +1253,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS static int find(char *d,int flagwild) { -@@ -105,6 +110,123 @@ +@@ -105,6 +110,122 @@ return response_addname(d1); } @@ -1323,8 +1323,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS + } + + /* Find covering hash */ -+ char nibble = ((digest[0] >> 4) & 0xf) + '0'; -+ if (nibble > '9') { nibble += 'a' - '9' - 1; } ++ char nibble = ((digest[0] >> 4) & 0xf) + 'A'; + salt[0] = 1; + salt[1] = nibble; + byte_copy(salt+2, dns_domain_length(control), control); @@ -1377,7 +1376,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS static int doit(char *q,char qtype[2]) { unsigned int bpos; -@@ -118,6 +240,8 @@ +@@ -118,6 +239,8 @@ int r; int flagns; int flagauthoritative; @@ -1386,7 +1385,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS char x[20]; uint16 u16; char addr[8][4]; -@@ -132,18 +256,28 @@ +@@ -132,18 +255,28 @@ for (;;) { flagns = 0; flagauthoritative = 0; @@ -1417,7 +1416,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS if (!flagauthoritative) { response[2] &= ~4; goto AUTHORITY; /* q is in a child zone */ -@@ -152,7 +286,11 @@ +@@ -152,7 +285,11 @@ flaggavesoa = 0; flagfound = 0; @@ -1430,7 +1429,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS for (;;) { addrnum = addr6num = 0; -@@ -162,8 +300,26 @@ +@@ -162,8 +299,26 @@ if (r == -1) return 0; flagfound = 1; if (flaggavesoa && byte_equal(type,2,DNS_T_SOA)) continue; @@ -1459,7 +1458,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS addrttl = ttl; i = dns_random(addrnum + 1); if (i < 8) { -@@ -174,7 +330,7 @@ +@@ -174,7 +329,7 @@ if (addrnum < 1000000) ++addrnum; continue; } @@ -1468,7 +1467,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS addr6ttl = ttl; i = dns_random(addr6num + 1); if (i < 8) { -@@ -188,6 +344,9 @@ +@@ -188,6 +343,9 @@ if (!response_rstart(q,type,ttl)) return 0; if (byte_equal(type,2,DNS_T_NS) || byte_equal(type,2,DNS_T_CNAME) || byte_equal(type,2,DNS_T_PTR)) { if (!doname()) return 0; @@ -1478,7 +1477,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS } else if (byte_equal(type,2,DNS_T_MX)) { if (!dobytes(2)) return 0; -@@ -199,6 +358,13 @@ +@@ -199,6 +357,13 @@ if (!dobytes(20)) return 0; flaggavesoa = 1; } @@ -1492,7 +1491,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS else if (!response_addbytes(data + dpos,dlen - dpos)) return 0; response_rfinish(RESPONSE_ANSWER); -@@ -219,10 +385,24 @@ +@@ -219,10 +384,24 @@ if (flagfound) break; if (wild == control) break; if (!*wild) break; /* impossible */ @@ -1517,7 +1516,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS if (!flagfound) response_nxdomain(); -@@ -230,22 +410,49 @@ +@@ -230,22 +409,49 @@ AUTHORITY: aupos = response_len; @@ -1579,7 +1578,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS cdb_findstart(&c); while (r = find(control,0)) { if (r == -1) return 0; -@@ -254,10 +461,33 @@ +@@ -254,10 +460,33 @@ if (!doname()) return 0; response_rfinish(RESPONSE_AUTHORITY); } @@ -1613,7 +1612,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS bpos = anpos; while (bpos < arpos) { -@@ -265,25 +495,33 @@ +@@ -265,25 +494,33 @@ bpos = dns_packet_copy(response,arpos,bpos,x,10); if (!bpos) return 0; if (byte_equal(x,2,DNS_T_NS) || byte_equal(x,2,DNS_T_MX)) { if (byte_equal(x,2,DNS_T_NS)) { @@ -1654,7 +1653,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS } } } -@@ -291,10 +529,10 @@ +@@ -291,10 +528,10 @@ bpos += u16; } @@ -1667,7 +1666,7 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS byte_zero(response + RESPONSE_AUTHORITY,2); response_len = aupos; } -@@ -316,6 +554,9 @@ +@@ -316,6 +553,9 @@ cdb_init(&c,fd); r = doit(q,qtype); @@ -1677,10 +1676,119 @@ diff -rNU3 djbdns-1.05.tds-base/TARGETS djbdns-1.05.tinydnssec/TARGETS cdb_free(&c); close(fd); -diff -rNU3 djbdns-1.05.tds-base/tinydns-data.c djbdns-1.05.tinydnssec/tinydns-data.c ---- djbdns-1.05.tds-base/tinydns-data.c 2012-12-06 22:45:38.000000000 +0100 -+++ djbdns-1.05.tinydnssec/tinydns-data.c 2012-12-06 22:39:13.000000000 +0100 -@@ -436,7 +436,7 @@ +--- djbdns-1.05.orig/tinydns-data.c 2020-05-31 12:26:32.153583322 +0200 ++++ djbdns-1.05/tinydns-data.c 2020-05-31 11:49:26.624848116 +0200 +@@ -155,14 +155,15 @@ + rr_add(buf,4); + rr_add(ttd,8); + } +-void rr_finish(const char *owner) ++void rr_finish(const char *owner, int to_lower) + { + if (byte_equal(owner,2,"\1*")) { + owner += 2; + result.s[2] -= 19; + } + if (!stralloc_copyb(&key,owner,dns_domain_length(owner))) nomem(); +- case_lowerb(key.s,key.len); ++ if (to_lower) ++ case_lowerb(key.s,key.len); + if (cdb_make_add(&cdb,key.s,key.len,result.s,result.len) == -1) + die_datatmp(); + } +@@ -295,7 +296,7 @@ + if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem(); + rr_addname(d2); + rr_add(soa,20); +- rr_finish(d1); ++ rr_finish(d1, 1); + break; + + case '.': case '&': +@@ -319,17 +320,17 @@ + rr_add("\12hostmaster",11); + rr_addname(d1); + rr_add(defaultsoa,20); +- rr_finish(d1); ++ rr_finish(d1, 1); + } + + rr_start(DNS_T_NS,ttl,ttd,loc); + rr_addname(d2); +- rr_finish(d1); ++ rr_finish(d1, 1); + + if (ip4_scan(f[1].s,ip)) { + rr_start(DNS_T_A,ttl,ttd,loc); + rr_add(ip,4); +- rr_finish(d2); ++ rr_finish(d2, 1); + } + + break; +@@ -346,13 +347,13 @@ + if (ip4_scan(f[1].s,ip)) { + rr_start(DNS_T_A,ttl,ttd,loc); + rr_add(ip,4); +- rr_finish(d1); ++ rr_finish(d1, 1); + + if (line.s[0] == '=') { + dns_name4_domain(dptr,ip); + rr_start(DNS_T_PTR,ttl,ttd,loc); + rr_addname(d1); +- rr_finish(dptr); ++ rr_finish(dptr, 1); + } + } + break; +@@ -368,18 +369,18 @@ + if (ip6_scan_flat(f[1].s,ip6)) { + rr_start(DNS_T_AAAA,ttl,ttd,loc); + rr_add(ip6,16); +- rr_finish(d1); ++ rr_finish(d1, 1); + + if (line.s[0] == '6') { /* emit both .ip6.arpa and .ip6.int */ + dns_name6_domain(d6ptr,ip6,DNS_IP6_ARPA); + rr_start(DNS_T_PTR,ttl,ttd,loc); + rr_addname(d1); +- rr_finish(d6ptr); ++ rr_finish(d6ptr, 1); + + dns_name6_domain(d6ptr,ip6,DNS_IP6_INT); + rr_start(DNS_T_PTR,ttl,ttd,loc); + rr_addname(d1); +- rr_finish(d6ptr); ++ rr_finish(d6ptr, 1); + } + } + break; +@@ -406,12 +407,12 @@ + uint16_pack_big(buf,u); + rr_add(buf,2); + rr_addname(d2); +- rr_finish(d1); ++ rr_finish(d1, 1); + + if (ip4_scan(f[1].s,ip)) { + rr_start(DNS_T_A,ttl,ttd,loc); + rr_add(ip,4); +- rr_finish(d2); ++ rr_finish(d2, 1); + } + break; + +@@ -428,7 +429,7 @@ + else + rr_start(DNS_T_PTR,ttl,ttd,loc); + rr_addname(d2); +- rr_finish(d1); ++ rr_finish(d1, 1); + break; + + case '\'': +@@ -444,14 +445,14 @@ i = 0; while (i < f[1].len) { k = f[1].len - i; @@ -1689,6 +1797,23 @@ diff -rNU3 djbdns-1.05.tds-base/tinydns-data.c djbdns-1.05.tinydnssec/tinydns-da ch = k; rr_add(&ch,1); rr_add(f[1].s + i,k); + i += k; + } + +- rr_finish(d1); ++ rr_finish(d1, 1); + break; + + case ':': +@@ -483,7 +484,7 @@ + + rr_start(type,ttl,ttd,loc); + rr_add(f[2].s,f[2].len); +- rr_finish(d1); ++ rr_finish(d1, u != 65282); /* preserve uppercase for hash database */ + break; + + default: diff -rNU3 djbdns-1.05.tds-base/tinydns-get.c djbdns-1.05.tinydnssec/tinydns-get.c --- djbdns-1.05.tds-base/tinydns-get.c 2001-02-11 22:11:45.000000000 +0100 +++ djbdns-1.05.tinydnssec/tinydns-get.c 2012-12-06 22:39:13.000000000 +0100 diff --git a/html/install.html b/html/install.html index fdc2a6b..ef78763 100644 --- a/html/install.html +++ b/html/install.html @@ -29,7 +29,8 @@

Requirements

Unfortunately, fefe refuses to name a license for this patch, which means that I cannot redistribute it. -
  • My own fixes to the Makefile (IPv6-related): djbdns-ipv6-make.patch
  • +
  • My own fixes to the Makefile (IPv6-related): + djbdns-ipv6-make.patch
  • Build

    @@ -37,7 +38,7 @@

    Build

    1. Download and unpack the original djbdns sources.
    2. Download and apply the patches listed above.
    3. -
    4. Download and unpack tinydnssec in +
    5. Download and unpack tinydnssec in the top-level source directory.
    6. Apply djbdns-1.05-dnssec.patch.
    7. Install as per @@ -72,7 +73,7 @@

      Test

      License information

      -(C) 2012,2015,2017,2019 Peter Conrad +(C) 2012,2015,2017,2019,2020 Peter Conrad

      This program is free software: you can redistribute it and/or modify diff --git a/run-tests.sh b/run-tests.sh index 3337a03..dd43254 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -30,6 +30,11 @@ set -e ########################################## # Test example zones and tinydns responses +( echo "managed-keys {"; + grep '^#K[^:]*:257:' test/data \ + | sed 's=^#K\([^:]*\):\([0-9]*\):\([0-9]*\):\([0-9]*\):\([^:]*\):.*= \1 initial-key \2 \3 \4 "\5";=' + echo "};" ) >test/trust.keys + ./tinydns-sign.pl test/example.?sk data ./tinydns-data rm data @@ -37,8 +42,8 @@ rm data for i in test/q-*; do id="${i#test/q}" echo -n "$i ... " - read sec type name <"$i" - ./tinydns-get "$sec" "$type" $name | tail -n +2 >test/"o$id" + read name zone type sec <"$i" + ./tinydns-get $sec "$type" $name$zone | tail -n +2 >test/"o$id" sed -s 's/\b[0-9]\{10\}\b/