diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2021-05-28 22:48:00 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2021-06-29 02:19:35 +0000 |
commit | 14ce22f4465622a94da073d0a8a76c105326b31c (patch) | |
tree | fd89b268ccb517be2329169e486da79045458bfa | |
parent | 0fa98cd38b59c9c05d717510f1d164af538dae90 (diff) | |
download | samba-14ce22f4465622a94da073d0a8a76c105326b31c.tar.gz |
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 <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | selftest/knownfail.d/dns-aging | 1 | ||||
-rw-r--r-- | source4/rpc_server/dnsserver/dnsdb.c | 37 |
2 files changed, 32 insertions, 6 deletions
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. */ |