Analysis workflow, fix ctime formatting for autotrust and testbound.

This commit is contained in:
W.C.A. Wijngaards 2021-06-25 15:11:10 +02:00
parent 770a54600c
commit e4e0eaa63e
6 changed files with 23 additions and 19 deletions

View 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;

View 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

1
configure vendored
View File

@ -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

View 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

View 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);
}

View 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);