]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
pdnsutil increase-serial: under SOA-EDIT=INCEPTION-EPOCH, bump as if it is EPOCH...
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 10 Sep 2019 10:53:29 +0000 (12:53 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 30 Oct 2019 11:56:59 +0000 (12:56 +0100)
pdns/serialtweaker.cc
regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command [new file with mode: 0755]
regression-tests/tests/pdnsutil-increase-serial-inception-epoch/description [new file with mode: 0644]
regression-tests/tests/pdnsutil-increase-serial-inception-epoch/expected_result [new file with mode: 0644]
regression-tests/tests/pdnsutil-increase-serial-inception-epoch/skip.nodyndns [new file with mode: 0644]

index 05300ee5346c204568a45eb87652a686e15c74c4..3ec6fe7494c3f6aad979a31e087ff0edcc1fc581 100644 (file)
@@ -89,7 +89,11 @@ static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increase
   if (pdns_iequals(increaseKind, "SOA-EDIT-INCREASE")) {
     uint32_t new_serial = old_serial;
     if (!editKind.empty()) {
-      new_serial = calculateEditSOA(old_serial, editKind, zonename);
+      if (pdns_iequals(editKind, "INCEPTION-EPOCH")) {
+        new_serial = calculateEditSOA(old_serial, "EPOCH", zonename);
+      } else {
+        new_serial = calculateEditSOA(old_serial, editKind, zonename);
+      }
     }
     if (new_serial <= old_serial) {
       new_serial = old_serial + 1;
diff --git a/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command
new file mode 100755 (executable)
index 0000000..86e86e9
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+NOW=$(date +%s)
+
+[ -z "$GMYSQLDB" ] && GMYSQLDB=pdnstest
+[ -z "$GMYSQLUSER" ] && GMYSQLUSER=root
+[ -z "$GMYSQLHOST" ] && GMYSQLHOST=localhost
+[ -z "$GMYSQLPASSWD" ] && GMYSQLPASSWD=''
+
+# lower SOA so that the test makes sense
+mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
+               "$GMYSQLDB" \
+               -e "UPDATE records SET content='ns1.test.dyndns ahu.example.dyndns 10 28800 7200 604800 86400' WHERE name='test.dyndns' AND type='SOA'"
+
+$PDNSUTIL --config-dir=. --config-name=gmysql list-zone test.dyndns | grep SOA
+
+$PDNSUTIL --config-dir=. --config-name=gmysql set-meta test.dyndns SOA-EDIT INCEPTION-EPOCH
+
+$PDNSUTIL --config-dir=. --config-name=gmysql increase-serial test.dyndns > /dev/null
+
+NEWSERIAL=$($PDNSUTIL --config-dir=. --config-name=gmysql list-zone test.dyndns | grep SOA | awk '{print $7}')
+
+NOWPLUSTEN=$((NOW + 10))
+
+if [ $NOW -le $NEWSERIAL ] && [ $NOW -le $NOWPLUSTEN ]
+then
+       echo New serial is within range
+else
+       echo New serial is NOT within range
+fi
+
+# remove meta
+$PDNSUTIL --config-dir=. --config-name=gmysql set-meta test.dyndns SOA-EDIT
+
+# restore old SOA
+mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
+               "$GMYSQLDB" \
+               -e "UPDATE records SET content='ns1.test.dyndns ahu.example.dyndns 2012060701 28800 7200 604800 86400' WHERE name='test.dyndns' AND type='SOA'"
diff --git a/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/description b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/description
new file mode 100644 (file)
index 0000000..754e9dc
--- /dev/null
@@ -0,0 +1 @@
+Make sure that pdnsutil increase-serial under INCEPTION-EPOCH bumps the serial to at least the current time.
diff --git a/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/expected_result b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/expected_result
new file mode 100644 (file)
index 0000000..d3e722d
--- /dev/null
@@ -0,0 +1,4 @@
+test.dyndns    3600    IN      SOA     ns1.test.dyndns ahu.example.dyndns 10 28800 7200 604800 86400
+Set 'test.dyndns' meta SOA-EDIT = INCEPTION-EPOCH
+New serial is within range
+Set 'test.dyndns' meta SOA-EDIT = 
diff --git a/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/skip.nodyndns b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/skip.nodyndns
new file mode 100644 (file)
index 0000000..81c071b
--- /dev/null
@@ -0,0 +1 @@
+Skip this test if the backend does not support dyndns/rfc2136