summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2020-05-03 20:24:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2020-05-03 20:24:03 +0000
commit792ce25af93bbd1f65632e31ce93b6ea08a3b80e (patch)
tree081ec74719c9386f7ddbc70075c387b10d0c800c /usr.sbin
parent1bf882b947102c604ec89c08325eaa84ed2f7672 (diff)
Use strftime() rather than ctime() to generate timestamps nicer.
ok job, input claudio benno
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rpki-client/output-json.c10
-rw-r--r--usr.sbin/rpki-client/output.c12
2 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/rpki-client/output-json.c b/usr.sbin/rpki-client/output-json.c
index 3fb69fdf9fb..452b7672bb0 100644
--- a/usr.sbin/rpki-client/output-json.c
+++ b/usr.sbin/rpki-client/output-json.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output-json.c,v 1.11 2020/05/03 19:41:54 deraadt Exp $ */
+/* $OpenBSD: output-json.c,v 1.12 2020/05/03 20:24:02 deraadt Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
*
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <time.h>
#include <netdb.h>
#include <openssl/ssl.h>
@@ -26,19 +27,20 @@ static int
outputheader_json(FILE *out, struct stats *st)
{
char hn[NI_MAXHOST], tbuf[26];
+ struct tm *tp;
time_t t;
time(&t);
setenv("TZ", "UTC", 1);
- ctime_r(&t, tbuf);
- *strrchr(tbuf, '\n') = '\0';
+ tp = localtime(&t);
+ strftime(tbuf, sizeof tbuf, "%FT%TZ", tp);
gethostname(hn, sizeof hn);
if (fprintf(out,
"{\n\t\"metadata\": {\n"
"\t\t\"buildmachine\": \"%s\",\n"
- "\t\t\"buildtime\": \"%s UTC\",\n"
+ "\t\t\"buildtime\": \"%s\",\n"
"\t\t\"elapsedtime\": \"%lld\",\n"
"\t\t\"usertime\": \"%lld\",\n"
"\t\t\"systemtime\": \"%lld\",\n"
diff --git a/usr.sbin/rpki-client/output.c b/usr.sbin/rpki-client/output.c
index ef544fccb81..442664a9b70 100644
--- a/usr.sbin/rpki-client/output.c
+++ b/usr.sbin/rpki-client/output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output.c,v 1.14 2020/05/03 19:41:54 deraadt Exp $ */
+/* $OpenBSD: output.c,v 1.15 2020/05/03 20:24:02 deraadt Exp $ */
/*
* Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org>
*
@@ -25,6 +25,7 @@
#include <string.h>
#include <limits.h>
#include <unistd.h>
+#include <time.h>
#include <openssl/x509v3.h>
@@ -173,18 +174,19 @@ set_signal_handler(void)
int
outputheader(FILE *out, struct stats *st)
{
- char hn[NI_MAXHOST], tbuf[26];
+ char hn[NI_MAXHOST], tbuf[80];
+ struct tm *tp;
time_t t;
time(&t);
setenv("TZ", "UTC", 1);
- ctime_r(&t, tbuf);
- *strrchr(tbuf, '\n') = '\0';
+ tp = localtime(&t);
+ strftime(tbuf, sizeof tbuf, "%a %b %e %H:%M:%S %Z %Y", tp);
gethostname(hn, sizeof hn);
if (fprintf(out,
- "# Generated on host %s at %s UTC\n"
+ "# Generated on host %s at %s\n"
"# Processing time %lld seconds (%lld seconds user, %lld seconds system)\n"
"# Route Origin Authorizations: %zu (%zu failed parse, %zu invalid)\n"
"# Certificates: %zu (%zu failed parse, %zu invalid)\n"