]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb/scavange dns: reserve NTTIME type for NTTIME values
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 27 Mar 2021 22:20:48 +0000 (11:20 +1300)
committerJeremy Allison <jra@samba.org>
Mon, 29 Mar 2021 23:20:37 +0000 (23:20 +0000)
We know it "really" just means uint64_t, but we also know it means
100-nanosecond intervals since 1601, and that makes any other use very
confusing (and not just to me, or there wouldn't be these bugs we're
chasing).

In these cases we are talking about 32 bit hours-since-1601 timestamps.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/dsdb/kcc/scavenge_dns_records.c
source4/dsdb/kcc/scavenge_dns_records.h

index 7504d3ac53610947e8028b378ae701b61c9846af..1a79795db37b33b7e14f323dc4cda0c1adee2cf4 100644 (file)
@@ -46,7 +46,7 @@
 NTSTATUS copy_current_records(TALLOC_CTX *mem_ctx,
                              struct ldb_message_element *old_el,
                              struct ldb_message_element *el,
-                             NTTIME t)
+                             uint32_t dns_timestamp)
 {
        unsigned int i, num_kept = 0;
        struct dnsp_DnssrvRpcRecord *recs = NULL;
@@ -75,7 +75,7 @@ NTSTATUS copy_current_records(TALLOC_CTX *mem_ctx,
                        DBG_ERR("Failed to pull dns rec blob.\n");
                        return NT_STATUS_INTERNAL_ERROR;
                }
-               if (recs[num_kept].dwTimeStamp > t ||
+               if (recs[num_kept].dwTimeStamp > dns_timestamp ||
                    recs[num_kept].dwTimeStamp == 0) {
                        num_kept++;
                }
@@ -117,7 +117,7 @@ NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
                                    struct dns_server_zone *zone,
                                    struct ldb_val *true_struct,
                                    struct ldb_val *tombstone_blob,
-                                   NTTIME t,
+                                   uint32_t dns_timestamp,
                                    char **error_string)
 {
        WERROR werr;
@@ -154,7 +154,7 @@ NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
 
        /* Subtract them from current time to get the earliest possible.
         * timestamp allowed for a non-expired DNS record. */
-       t -= zi->dwNoRefreshInterval + zi->dwRefreshInterval;
+       dns_timestamp -= zi->dwNoRefreshInterval + zi->dwRefreshInterval;
 
        /* Custom match gets dns records in the zone with dwTimeStamp < t. */
        ret = ldb_search(samdb,
@@ -166,8 +166,8 @@ NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
                         "(&(objectClass=dnsNode)"
                         "(&(!(dnsTombstoned=TRUE))"
                         "(dnsRecord:" DSDB_MATCH_FOR_DNS_TO_TOMBSTONE_TIME
-                        ":=%"PRIu64")))",
-                        t);
+                        ":=%"PRIu32")))",
+                        dns_timestamp);
        if (ret != LDB_SUCCESS) {
                *error_string = talloc_asprintf(mem_ctx,
                                                "Failed to search for dns "
@@ -213,7 +213,7 @@ NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
                }
 
                el->num_values = old_el->num_values;
-               status = copy_current_records(mem_ctx, old_el, el, t);
+               status = copy_current_records(mem_ctx, old_el, el, dns_timestamp);
 
                if (!NT_STATUS_IS_OK(status)) {
                        TALLOC_FREE(old_msg);
index 799fedba258575135cda95936f71fdfc1179b1f1..d97586c97bbb4b80f92acc23c114d44d37f7bafc 100644 (file)
@@ -39,10 +39,10 @@ NTSTATUS dns_tombstone_records_zone(TALLOC_CTX *mem_ctx,
                                    struct dns_server_zone *zone,
                                    struct ldb_val *true_struct,
                                    struct ldb_val *tombstone_blob,
-                                   NTTIME t,
+                                   uint32_t dns_timestamp,
                                    char **error_string);
 
 NTSTATUS copy_current_records(TALLOC_CTX *mem_ctx,
                              struct ldb_message_element *old_el,
                              struct ldb_message_element *el,
-                             NTTIME t);
+                             uint32_t dns_timestamp);