]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
dump: allow rrsig timestamps past year 2106 in txt format...
authorLibor Peltan <libor.peltan@nic.cz>
Fri, 28 Jan 2022 16:58:00 +0000 (17:58 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Fri, 4 Mar 2022 12:14:01 +0000 (13:14 +0100)
...and optimized not to obtain time(NULL) on every
dumped rdata in the cases of zone file, kdig and kjournalprint

src/knot/updates/changesets.c
src/knot/zone/zone-dump.c
src/libknot/rrset-dump.c
src/libknot/rrset-dump.h
src/utils/kdig/kdig_params.c

index a70b3fe747ded57d338e28dcb969d355f230dbe6..d9c9d24f281e2df470634fd17edcb2b996862c75 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 #include "knot/updates/apply.h"
 #include "knot/zone/zone-dump.h"
 #include "contrib/color.h"
+#include "contrib/time.h"
 #include "libknot/libknot.h"
 
 static int handle_soa(knot_rrset_t **soa, const knot_rrset_t *rrset)
@@ -590,6 +591,7 @@ void changeset_print(const changeset_t *changeset, FILE *outfile, bool color)
        char *buff = malloc(buflen);
 
        knot_dump_style_t style = KNOT_DUMP_STYLE_DEFAULT;
+       style.now = knot_time();
 
        style.color = COL_RED(color);
        if (changeset->soa_from != NULL || !zone_contents_is_empty(changeset->remove)) {
index 83b9ff7b95b26b2d9c0268635ad3321a852ceeb4..41ec9254614e6242298ae33515fc51a0d863ed5c 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -158,6 +158,7 @@ int zone_dump_text(zone_contents_t *zone, FILE *file, bool comments, const char
        // Set structure with parameters.
        knot_dump_style_t style = KNOT_DUMP_STYLE_DEFAULT;
        style.color = color;
+       style.now = knot_time();
        dump_params_t params = {
                .file = file,
                .buf = buf,
index 25caae9826d96b5caa5621152d53aba66d828dc8..51e29c2b77e0166374a6c5a820b85a9d8a0d3df8 100644 (file)
@@ -41,6 +41,7 @@
 #include "contrib/base64.h"
 #include "contrib/color.h"
 #include "contrib/ctype.h"
+#include "contrib/time.h"
 #include "contrib/wire_ctx.h"
 
 #define RRSET_DUMP_LIMIT (2 * 1024 * 1024)
@@ -87,6 +88,7 @@ const knot_dump_style_t KNOT_DUMP_STYLE_DEFAULT = {
        .hide_crypto = false,
        .ascii_to_idn = NULL,
        .color = NULL,
+       .now = 0,
 };
 
 static void dump_string(rrset_dump_params_t *p, const char *str)
@@ -685,6 +687,9 @@ static void wire_timestamp_to_str(rrset_dump_params_t *p)
        FILL_IN_INPUT(data)
 
        time_t timestamp = ntohl(data);
+       if (sizeof(time_t) > 4) {
+               timestamp = knot_time_from_u32(timestamp, p->style->now);
+       }
 
        if (p->style->human_timestamp) {
                struct tm result;
index da7dc2c745a92a6acbba0cbbd6cd62c57651377f..4631531758d94ffe43d9de3c4c77f3228768ab1c 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -56,6 +56,8 @@ typedef struct {
        /*!< Optional color control sequence which is put before every output line.
         *   Not compatible with wrap. */
        const char *color;
+       /*!< Time context for correct > 32 bit timestamp conversion. */
+       uint64_t now;
 } knot_dump_style_t;
 
 /*! \brief Default dump style. */
index 3fc43c7a96b8e7bfd33e149836edf58de65afc97..2cef812bcbf15397e25c2c4e63623a48e7eb83e8 100644 (file)
@@ -33,6 +33,7 @@
 #include "contrib/sockaddr.h"
 #include "contrib/string.h"
 #include "contrib/strtonum.h"
+#include "contrib/time.h"
 #include "contrib/ucw/lists.h"
 #include "libdnssec/error.h"
 #include "libdnssec/random.h"
@@ -1512,6 +1513,7 @@ query_t *query_create(const char *owner, const query_t *conf)
                query->notify = false;
                query->flags = DEFAULT_FLAGS_DIG;
                query->style = DEFAULT_STYLE_DIG;
+               query->style.style.now = knot_time();
                query->idn = true;
                query->nsid = false;
                query->edns = -1;