From: Peter van Dijk Date: Tue, 10 Sep 2019 10:53:29 +0000 (+0200) Subject: pdnsutil increase-serial: under SOA-EDIT=INCEPTION-EPOCH, bump as if it is EPOCH... X-Git-Tag: dnsdist-1.4.0~20^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=865d5504f6cf1aeb317765f15d0fc3cfe0ca76df;p=thirdparty%2Fpdns.git pdnsutil increase-serial: under SOA-EDIT=INCEPTION-EPOCH, bump as if it is EPOCH, fixes #8218 --- diff --git a/pdns/serialtweaker.cc b/pdns/serialtweaker.cc index 05300ee534..3ec6fe7494 100644 --- a/pdns/serialtweaker.cc +++ b/pdns/serialtweaker.cc @@ -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 index 0000000000..86e86e9100 --- /dev/null +++ b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command @@ -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 index 0000000000..754e9dc808 --- /dev/null +++ b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/description @@ -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 index 0000000000..d3e722d546 --- /dev/null +++ b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/expected_result @@ -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 index 0000000000..81c071b810 --- /dev/null +++ b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/skip.nodyndns @@ -0,0 +1 @@ +Skip this test if the backend does not support dyndns/rfc2136