From f6abf60f55808bf9e8fb7310bebf6c2306787f9b Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Apr 18 2011 21:57:15 +0000 Subject: - make the not-valid-after date easier to read when displaying it --- diff --git a/src/getcert.c b/src/getcert.c index 51d9a91..b5ceafd 100644 --- a/src/getcert.c +++ b/src/getcert.c @@ -1721,7 +1721,7 @@ list(const char *argv0, int argc, char **argv) dbus_bool_t b; char *s1, *s2, *s3, *s4, *s5, *s6; long n1, n2; - char **as1, **as2, **as3, **as4, t[15]; + char **as1, **as2, **as3, **as4, t[24]; int requests_only = 0, tracking_only = 0, verbose = 0, c, i, j; while ((c = getopt(argc, argv, "rtsSv" GETOPT_CA)) != -1) { switch (c) { @@ -1910,7 +1910,9 @@ list(const char *argv0, int argc, char **argv) printf(_("\tissuer: %s\n"), s1); printf(_("\tsubject: %s\n"), s3); printf(_("\texpires: %s\n"), - n1 ? cm_store_timestamp_from_time(n1, t) : _("unknown")); + n1 ? + cm_store_timestamp_from_time_for_display(n1, t) : + _("unknown")); for (j = 0; (as1 != NULL) && (as1[j] != NULL); j++) { printf("%s%s%s", j == 0 ? _("\temail: ") : ",", diff --git a/src/store-gen.c b/src/store-gen.c index 1c33b2c..1828b93 100644 --- a/src/store-gen.c +++ b/src/store-gen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2009,2011 Red Hat, Inc. * * 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 @@ -194,6 +194,20 @@ cm_store_timestamp_from_time(time_t when, char timestamp[15]) } char * +cm_store_timestamp_from_time_for_display(time_t when, char timestamp[21]) +{ + struct tm tm; + if ((when != 0) && (gmtime_r(&when, &tm) == &tm)) { + sprintf(timestamp, "%04d-%02d-%02d %02d:%02d:%02d UTC", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); + } else { + strcpy(timestamp, "19700101000000"); + } + return timestamp; +} + +char * cm_store_increment_serial(void *parent, const char *old_serial) { char *tmp, *serial; diff --git a/src/store.h b/src/store.h index 651dd59..40f2f31 100644 --- a/src/store.h +++ b/src/store.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2009,2011 Red Hat, Inc. * * 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 @@ -38,6 +38,7 @@ struct cm_store_ca **cm_store_get_all_cas(void *parent); /* Utility functions. */ time_t cm_store_time_from_timestamp(const char *timestamp); char *cm_store_timestamp_from_time(time_t when, char timestamp[15]); +char *cm_store_timestamp_from_time_for_display(time_t when, char timestamp[24]); char *cm_store_increment_serial(void *parent, const char *old_serial); char *cm_store_serial_from_binary(void *parent, const unsigned char *serial, int length);