]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc dnsserver: improve handling of serial numbers
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 28 May 2021 10:48:00 +0000 (22:48 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 29 Jun 2021 02:19:35 +0000 (02:19 +0000)
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>
selftest/knownfail.d/dns-aging
source4/rpc_server/dnsserver/dnsdb.c

index bcea801187200bd17f6894891c8de504e29ecf98..bff873cc1ca0f583d7e3a71d090841d9d626ae67 100644 (file)
@@ -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
index 0834d54a4071129922a391b9aee14dbfc41fb708..bde54a0ddfcb775d0bb0699c8a438de27407fda7 100644 (file)
@@ -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. */