]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Analysis workflow, fix ctime formatting for autotrust and testbound.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 25 Jun 2021 13:11:10 +0000 (15:11 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 25 Jun 2021 13:11:10 +0000 (15:11 +0200)
compat/ctime_r.c
config.h.in
configure
configure.ac
testcode/replay.c
validator/autotrust.c

index d6133cb02f5fed0083d3d64713ce1f2012988687..9f2bf15bcbed4bffe9fa30a53d5acf435dda4a7b 100644 (file)
@@ -23,7 +23,6 @@ ctime_r_cleanup(void)
 char *ctime_r(const time_t *timep, char *buf)
 {
        char* result;
-       printf("unbound_ctime_r called\n");
        if(!ctime_r_init) {
                /* still small race where this init can be done twice,
                 * which is mostly harmless */
@@ -34,11 +33,9 @@ char *ctime_r(const time_t *timep, char *buf)
        lock_basic_lock(&ctime_lock);
        result = ctime(timep);
        if(buf && result) {
-               printf("ctime_r called result '%s'\n", result);
                if(strlen(result) > 10 && result[7]==' ' && result[8]=='0')
                        result[8]=' '; /* fix error in windows ctime */
                strcpy(buf, result);
-               printf("ctime_r called fixresult '%s'\n", buf);
        }
        lock_basic_unlock(&ctime_lock);
        return buf;
index 385ea3cdeb32b971823dc4b0f25d966c16099249..cb27afa4fe27e63a34407f1f9c1e0f5fefc253b8 100644 (file)
@@ -1263,9 +1263,6 @@ int memcmp(const void *x, const void *y, size_t n);
 
 
 #ifndef HAVE_CTIME_R
-#ifdef ctime_r
-#undef ctime_r
-#endif
 #define ctime_r unbound_ctime_r
 char *ctime_r(const time_t *timep, char *buf);
 #endif
index c86635be49976d5286a617c101c3471a9ff63e16..3ed5daddaaa8a957c49716760c22385040b04e01 100755 (executable)
--- a/configure
+++ b/configure
@@ -21048,7 +21048,6 @@ esac
 fi
 
 
-#LIBOBJS="$LIBOBJS ctime_r.$ac_objext"
 ac_fn_c_check_func "$LINENO" "strsep" "ac_cv_func_strsep"
 if test "x$ac_cv_func_strsep" = xyes; then :
   $as_echo "#define HAVE_STRSEP 1" >>confdefs.h
index 1d22e363311e010970c200eee637a9f392651f1d..5ffbe68344ec26cf6f44078637d4961876e6fc78 100644 (file)
@@ -1717,7 +1717,6 @@ fi
 LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
 AC_SUBST(LIBOBJ_WITHOUT_CTIME)
 AC_REPLACE_FUNCS(ctime_r)
-#LIBOBJS="$LIBOBJS ctime_r.$ac_objext"
 AC_REPLACE_FUNCS(strsep)
 
 AC_ARG_ENABLE(allsymbols, AS_HELP_STRING([--enable-allsymbols],[export all symbols from libunbound and link binaries to it, smaller install size but libunbound export table is polluted by internal symbols]))
@@ -2045,9 +2044,6 @@ AHX_MEMCMP_BROKEN(unbound)
 
 [
 #ifndef HAVE_CTIME_R
-#ifdef ctime_r
-#undef ctime_r
-#endif
 #define ctime_r unbound_ctime_r
 char *ctime_r(const time_t *timep, char *buf);
 #endif
index 69f1544db8739c52c0b2112cac7ba81d48e53e4e..37221eda3967fb0023f36f0ac54bd0116d0f7331 100644 (file)
@@ -688,6 +688,10 @@ do_macro_ctime(char* arg)
                return NULL;
        }
        ctime_r(&tt, buf);
+#ifdef USE_WINSOCK
+       if(strlen(buf) > 10 && buf[7]==' ' && buf[8]=='0')
+               buf[8]=' '; /* fix error in windows ctime */
+#endif
        strip_end_white(buf);
        return strdup(buf);
 }
index adf8367543929c8a14a5765b1a7f6db301543a51..fe17df2d5ed166a6a8470eb783aec38b21dd57af 100644 (file)
@@ -1077,6 +1077,17 @@ trustanchor_state2str(autr_state_type s)
         return " UNKNOWN ";
 }
 
+/** ctime r for autotrust */
+static char* autr_ctime_r(time_t* t, char* s)
+{
+       ctime_r(t, s);
+#ifdef USE_WINSOCK
+       if(strlen(s) > 10 && s[7]==' ' && s[8]=='0')
+               s[8]=' '; /* fix error in windows ctime */
+#endif
+       return s;
+}
+
 /** print ID to file */
 static int
 print_id(FILE* out, char* fname, uint8_t* nm, size_t nmlen, uint16_t dclass)
@@ -1123,13 +1134,13 @@ autr_write_contents(FILE* out, char* fn, struct trust_anchor* tp)
        }
        if(fprintf(out, ";;last_queried: %u ;;%s", 
                (unsigned int)tp->autr->last_queried, 
-               ctime_r(&(tp->autr->last_queried), tmi)) < 0 ||
+               autr_ctime_r(&(tp->autr->last_queried), tmi)) < 0 ||
           fprintf(out, ";;last_success: %u ;;%s", 
                (unsigned int)tp->autr->last_success,
-               ctime_r(&(tp->autr->last_success), tmi)) < 0 ||
+               autr_ctime_r(&(tp->autr->last_success), tmi)) < 0 ||
           fprintf(out, ";;next_probe_time: %u ;;%s", 
                (unsigned int)tp->autr->next_probe_time,
-               ctime_r(&(tp->autr->next_probe_time), tmi)) < 0 ||
+               autr_ctime_r(&(tp->autr->next_probe_time), tmi)) < 0 ||
           fprintf(out, ";;query_failed: %d\n", (int)tp->autr->query_failed)<0
           || fprintf(out, ";;query_interval: %d\n", 
           (int)tp->autr->query_interval) < 0 ||
@@ -1160,7 +1171,7 @@ autr_write_contents(FILE* out, char* fn, struct trust_anchor* tp)
                        ";;lastchange=%u ;;%s", str, (int)ta->s, 
                        trustanchor_state2str(ta->s), (int)ta->pending_count,
                        (unsigned int)ta->last_change, 
-                       ctime_r(&(ta->last_change), tmi)) < 0) {
+                       autr_ctime_r(&(ta->last_change), tmi)) < 0) {
                   log_err("could not write to %s: %s", fn, strerror(errno));
                   free(str);
                   return 0;
@@ -2264,7 +2275,7 @@ autr_debug_print_ta(struct autr_ta* ta)
                return;
        }
        if(str[0]) str[strlen(str)-1]=0; /* remove newline */
-       ctime_r(&ta->last_change, buf);
+       autr_ctime_r(&ta->last_change, buf);
        if(buf[0]) buf[strlen(buf)-1]=0; /* remove newline */
        log_info("[%s] %s ;;state:%d ;;pending_count:%d%s%s last:%s",
                trustanchor_state2str(ta->s), str, ta->s, ta->pending_count,
@@ -2291,13 +2302,13 @@ autr_debug_print_tp(struct trust_anchor* tp)
                log_packed_rrset(NO_VERBOSE, "DNSKEY:", tp->dnskey_rrset);
        }
        log_info("file %s", tp->autr->file);
-       ctime_r(&tp->autr->last_queried, buf);
+       autr_ctime_r(&tp->autr->last_queried, buf);
        if(buf[0]) buf[strlen(buf)-1]=0; /* remove newline */
        log_info("last_queried: %u %s", (unsigned)tp->autr->last_queried, buf);
-       ctime_r(&tp->autr->last_success, buf);
+       autr_ctime_r(&tp->autr->last_success, buf);
        if(buf[0]) buf[strlen(buf)-1]=0; /* remove newline */
        log_info("last_success: %u %s", (unsigned)tp->autr->last_success, buf);
-       ctime_r(&tp->autr->next_probe_time, buf);
+       autr_ctime_r(&tp->autr->next_probe_time, buf);
        if(buf[0]) buf[strlen(buf)-1]=0; /* remove newline */
        log_info("next_probe_time: %u %s", (unsigned)tp->autr->next_probe_time,
                buf);