1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

dns: use unix_to_dns_timestamp almost everywhere

In places we change NTTIME to uint32_t, because that is what is
actually wanted.

There is one instance of the calculation that we are not changing,
because there are other problems there.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Douglas Bagnall 2021-03-11 15:58:37 +13:00 committed by Jeremy Allison
parent 146c23fb7d
commit a32c229b09
4 changed files with 6 additions and 18 deletions

View File

@ -1908,7 +1908,6 @@ _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo
uint16_t num_recs = 0;
uint16_t first = 0;
uint16_t i;
NTTIME t;
WERROR werr;
if (state->transaction_token != (void*)version) {
@ -1993,10 +1992,7 @@ _PUBLIC_ isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, vo
if (dns_name_is_static(recs, num_recs)) {
rec->dwTimeStamp = 0;
} else {
unix_to_nt_time(&t, time(NULL));
t /= 10 * 1000 * 1000; /* convert to seconds */
t /= 3600; /* convert to hours */
rec->dwTimeStamp = (uint32_t)t;
rec->dwTimeStamp = unix_to_dns_timestamp(time(NULL));
}
}

View File

@ -302,7 +302,6 @@ static WERROR dns_rr_to_dnsp(TALLOC_CTX *mem_ctx,
bool name_is_static)
{
enum ndr_err_code ndr_err;
NTTIME t;
if (rrec->rr_type == DNS_QTYPE_ALL) {
return DNS_ERR(FORMAT_ERROR);
@ -316,10 +315,7 @@ static WERROR dns_rr_to_dnsp(TALLOC_CTX *mem_ctx,
if (name_is_static) {
r->dwTimeStamp = 0;
} else {
unix_to_nt_time(&t, time(NULL));
t /= 10 * 1000 * 1000;
t /= 3600;
r->dwTimeStamp = t;
r->dwTimeStamp = unix_to_dns_timestamp(time(NULL));
}
/* If we get QCLASS_ANY, we're done here */

View File

@ -941,7 +941,7 @@ WERROR dns_common_replace(struct ldb_context *samdb,
bool become_tombstoned = false;
struct ldb_dn *zone_dn = NULL;
struct dnsserver_zoneinfo *zoneinfo = NULL;
NTTIME t;
uint32_t t;
msg = ldb_msg_new(mem_ctx);
W_ERROR_HAVE_NO_MEMORY(msg);
@ -1015,9 +1015,7 @@ WERROR dns_common_replace(struct ldb_context *samdb,
}
if (zoneinfo->fAging == 1 && records[i].dwTimeStamp != 0) {
unix_to_nt_time(&t, time(NULL));
t /= 10 * 1000 * 1000;
t /= 3600;
t = unix_to_dns_timestamp(time(NULL));
if (t - records[i].dwTimeStamp >
zoneinfo->dwNoRefreshInterval) {
records[i].dwTimeStamp = t;

View File

@ -381,7 +381,7 @@ NTSTATUS dns_delete_tombstones(TALLOC_CTX *mem_ctx,
struct dns_server_zone *zones = NULL;
struct dns_server_zone *z = NULL;
int ret, i;
NTTIME current_time;
uint32_t current_time;
enum ndr_err_code ndr_err;
struct ldb_result *res = NULL;
int tombstone_time;
@ -392,9 +392,7 @@ NTSTATUS dns_delete_tombstones(TALLOC_CTX *mem_ctx,
const char *attrs[] = {"dnsRecord", "dNSTombstoned", NULL};
rec = talloc_zero(mem_ctx, struct dnsp_DnssrvRpcRecord);
unix_to_nt_time(&current_time, time(NULL));
current_time /= 10 * 1000 * 1000;
current_time /= 3600;
current_time = unix_to_dns_timestamp(time(NULL));
lp_ctx = (struct loadparm_context *)ldb_get_opaque(samdb, "loadparm");
tombstone_time =