From: Douglas Bagnall Date: Fri, 28 May 2021 10:48:00 +0000 (+1200) Subject: rpc dnsserver: improve handling of serial numbers X-Git-Tag: tevent-0.11.0~152 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14ce22f4465622a94da073d0a8a76c105326b31c;p=thirdparty%2Fsamba.git rpc dnsserver: improve handling of serial numbers This is not correct, but it gets closer. We need to save the updated serial number in the SOA. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/selftest/knownfail.d/dns-aging b/selftest/knownfail.d/dns-aging index bcea8011872..bff873cc1ca 100644 --- a/selftest/knownfail.d/dns-aging +++ b/selftest/knownfail.d/dns-aging @@ -31,7 +31,6 @@ samba.tests.dns_aging.+test_dns_add_sibling_2_7_days_aging samba.tests.dns_aging.+test_dns_add_sibling_2_7_days_aging_touch samba.tests.dns_aging.+test_dns_add_sibling_2_7_days_no_aging_touch samba.tests.dns_aging.+test_add_update_dwFlags -samba.tests.dns_aging.+test_add_update_dwReserved samba.tests.dns_aging.+test_add_update_dwSerial samba.tests.dns_aging.+test_add_update_dwSerial_2 samba.tests.dns_aging.+test_add_update_many diff --git a/source4/rpc_server/dnsserver/dnsdb.c b/source4/rpc_server/dnsserver/dnsdb.c index 0834d54a407..bde54a0ddfc 100644 --- a/source4/rpc_server/dnsserver/dnsdb.c +++ b/source4/rpc_server/dnsserver/dnsdb.c @@ -641,6 +641,11 @@ WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx, } if (dns_record_match(drec, &rec2)) { + /* + * we are replacing this one with arec, which is done + * by pushing arec into el->values[i] below, after the + * various manipulations. + */ break; } } @@ -648,13 +653,35 @@ WERROR dnsserver_db_update_record(TALLOC_CTX *mem_ctx, return WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST; } - /* If updating SOA record, use specified serial, otherwise increment */ + /* + * If we're updating a SOA record, use the specified serial. + * + * Otherwise, if we are updating ttl in place (i.e., not changing + * .wType and .data on a record), we should increment the existing + * serial, and save to the SOA. + * + * Outside of those two cases, we look for the zone's SOA record and + * use its serial. + */ if (arec->wType != DNS_TYPE_SOA) { - serial = dnsserver_update_soa(mem_ctx, samdb, z, &werr); - if (serial < 0) { - return werr; + if (updating_ttl) { + /* + * In this case, we keep some of the old values. + */ + arec->dwSerial = rec2.dwSerial; + arec->dwReserved = rec2.dwReserved; + /* + * TODO: if the old TTL and the new TTL are + * different, the serial number is incremented. + */ + } else { + arec->dwReserved = 0; + serial = dnsserver_update_soa(mem_ctx, samdb, z, &werr); + if (serial < 0) { + return werr; + } + arec->dwSerial = serial; } - arec->dwSerial = serial; } /* Set the correct rank for the record. */