]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dns scavenging: correctly set tombstome timestamp
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 27 Mar 2021 09:59:08 +0000 (22:59 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 20 Jun 2021 23:26:32 +0000 (23:26 +0000)
In a DNS tombstone record, the dwTimestamp is, as always, uint32_t hours
since 1601, while the wType-switched .data.EntombedTime timestamp is NTTIME.

We had that wrong, putting the hours in both places.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/kcc/scavenge_dns_records.c

index e82d834e94f74943d6304b7f82b44e0ed0d955fb..7100c61326da3139337d8d9164cb9575e8955da4 100644 (file)
@@ -324,17 +324,20 @@ NTSTATUS dns_tombstone_records(TALLOC_CTX *mem_ctx,
        struct dnsp_DnssrvRpcRecord tombstone_struct;
        struct ldb_val tombstone_blob;
        struct ldb_val true_struct;
-       NTTIME t;
+       uint32_t dns_timestamp;
+       NTTIME nttime;
        enum ndr_err_code ndr_err;
        TALLOC_CTX *tmp_ctx = NULL;
        uint8_t true_str[4] = "TRUE";
+       time_t unix_now = time(NULL);
 
-       unix_to_nt_time(&t, time(NULL));
-       t /= 10 * 1000 * 1000;
-       t /= 3600;
+       unix_to_nt_time(&nttime, unix_now);
+       dns_timestamp = unix_to_dns_timestamp(unix_now);
 
        tombstone_struct = (struct dnsp_DnssrvRpcRecord){
-           .wType = DNS_TYPE_TOMBSTONE, .data = {.EntombedTime = t}};
+           .wType = DNS_TYPE_TOMBSTONE,
+           .data = {.EntombedTime = nttime}
+       };
 
        true_struct = (struct ldb_val){.data = true_str, .length = 4};
 
@@ -358,7 +361,7 @@ NTSTATUS dns_tombstone_records(TALLOC_CTX *mem_ctx,
                                                 z,
                                                 &true_struct,
                                                 &tombstone_blob,
-                                                t,
+                                                dns_timestamp,
                                                 error_string);
                TALLOC_FREE(tmp_ctx);
                if (NT_STATUS_EQUAL(ret, NT_STATUS_PROPSET_NOT_FOUND)) {