Skip Menu |
 

Subject: add more strftime format strings for klist
"Hey kaduk, might I recommend "%x %R" as another option before falling
back on "%d/%m/%Y %R"?"
"I'd also try "%x %T""
klist ends up calling krb5_timestamp_to_sfstring() with a max length of 20, which prevents it
from using some of the strftime() formats in some locales. In the en_US.UTF-8 locale on recent
versions of Ubuntu, none of the formats except the European date-order format "%d/%m/%Y %R"
fits in the allotted space. Relatedly, we shouldn't hard code potentially ambiguous date formats,
so consider using "%Y-%m-%dT%H:%M:%S", "%Y%m%dT%H%M%S", or "%Y%m%d%H%M%S" as a final
fallback. (These are ISO 8601 date-and-time formats.)
It's also worth noting that there's an fallback to use sprintf to format using the equivalent of
"%d/%m/%Y %H:%M" if none of the strftime formats works. We should probably remove this
fallback sprintf format because it is ambiguous (European vs US date order). Can we also
assume a working strftime as well, considering that we appear to attempt to build a replacement
if it's not found?
From: Russ Allbery <rra@stanford.edu>
To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #7458] add more strftime format strings for klist
Date: Thu, 20 Dec 2012 12:44:22 -0800
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1.1KiB
"Tom Yu via RT" <rt-comment@krbdev.mit.edu> writes:

Show quoted text
> It's also worth noting that there's an fallback to use sprintf to format
> using the equivalent of "%d/%m/%Y %H:%M" if none of the strftime formats
> works. We should probably remove this fallback sprintf format because
> it is ambiguous (European vs US date order). Can we also assume a
> working strftime as well, considering that we appear to attempt to build
> a replacement if it's not found?

strftime is sufficiently universal that gnulib doesn't even bother to cope
with its absence. I've never encountered a system where someone wanted to
build my software that didn't have it.

gnulib says this about the Windows implementation:

The Windows C runtime library (which is used by MinGW) does not
support the %e specifier (and possibly the other more recent SUS
specifiers too, i.e., %C, %D, %h, %n, %r, %R, %t, and %T).

My recommendation would be to even remove the replacement version and
assume that the system has it, but ensure that you have a fallback format
that doesn't include any of the above specifiers.

--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Proposed patches in
https://github.com/tlyu/krb5/commits/ts2sfstr

The deletion of the sprintf() fallback will probably not get pulled up to the krb5-1.11 branch.
From: tlyu@mit.edu
Subject: SVN Commit

Add more formats to krb5_timestamp_to_sfstring

krb5_timestamp_to_string() can produce ambiguous dates. The final
fallback, "%d/%m/%Y %R", contains a European order date format that
can be confused with a US date format. Add some additional strftime()
format strings, including locale-dependent formats and some ISO 8601
formats. Remove the hardcoded strftime() format that had an ambiguous
date order.

https://github.com/krb5/krb5/commit/e8e34ead59b3e1fd28beb151c5e6efb47bc57bee
Author: Tom Yu <tlyu@mit.edu>
Commit: e8e34ead59b3e1fd28beb151c5e6efb47bc57bee
Branch: master
src/lib/krb5/krb/str_conv.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
From: tlyu@mit.edu
Subject: SVN Commit

Add more formats to krb5_timestamp_to_sfstring

krb5_timestamp_to_string() can produce ambiguous dates. The final
fallback, "%d/%m/%Y %R", contains a European order date format that
can be confused with a US date format. Add some additional strftime()
format strings, including locale-dependent formats and some ISO 8601
formats. Remove the hardcoded strftime() format that had an ambiguous
date order.

(cherry picked from commit e8e34ead59b3e1fd28beb151c5e6efb47bc57bee)

https://github.com/krb5/krb5/commit/f19ba6a57b9938591be5a121467bfdd33ce09fdf
Author: Tom Yu <tlyu@mit.edu>
Commit: f19ba6a57b9938591be5a121467bfdd33ce09fdf
Branch: krb5-1.11
src/lib/krb5/krb/str_conv.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)