Skip Menu |
 

Subject: klist does not use localized time formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dr-wily:~> klist
Ticket cache: FILE:/tmp/krb5cc_20922_J15255
Default principal: sipbtest@ATHENA.MIT.EDU

Valid starting Expires Service principal
07/05/12 16:22:23 07/06/12 13:37:23 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
renew until 07/06/12 16:22:23
dr-wily:~> setenv LC_ALL fr_FR.UTF-8
dr-wily:~> klist
Ticket cache: FILE:/tmp/krb5cc_20922_J15255
Default principal: sipbtest@ATHENA.MIT.EDU

Valid starting Expires Service principal
07/05/12 16:22:23 07/06/12 13:37:23 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
renew until 07/06/12 16:22:23
dr-wily:~> date
jeudi 5 juillet 2012, 16:22:44 (UTC-0400)
%%%%%%%%%%%%%%%%%%%%%%
The format mm/dd/yy is highly US-centric, and dates will render
differently in other locales.
From: Sam Hartman <hartmans@mit.edu>
To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #7192] klist does not use localized time formatting
Date: Thu, 05 Jul 2012 16:40:48 -0400
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1.4KiB
Here's the patch we're using in Debian for this:
I was planning on submitting after it made it into a Debian release:

Obviously the log message needs updating.

From c13c7a9a3da805d69194e7841d9dc1a89e8bf2ba Mon Sep 17 00:00:00 2001
From: Sam Hartman <hartmans@debian.org>
Date: Tue, 29 Nov 2011 19:40:23 -0500
Subject: =?UTF-8?q?ticket:=20new=0Asubject:=20Respect=20locale=20for=20time=20?=
=?UTF-8?q?display?=

Call setlocale(LC_TIME) in klist and kadmin to get locale-specific
time display.

Patch-Name: time_locale
---
src/clients/klist/klist.c | 1 +
src/kadmin/cli/ss_wrapper.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c
index a9a917156f526e32b171de9be16356abbce9e4cd..f0d55e8 100644
--- a/src/clients/klist/klist.c
+++ b/src/clients/klist/klist.c
@@ -119,6 +119,7 @@ main(argc, argv)
int mode;

setlocale(LC_MESSAGES, "");
+ setlocale(LC_TIME, "");
progname = GET_PROGNAME(argv[0]);

name = NULL;
diff --git a/src/kadmin/cli/ss_wrapper.c b/src/kadmin/cli/ss_wrapper.c
index f86c215f0485df127f7d624df2afded46c2db33d..2608d8c 100644
--- a/src/kadmin/cli/ss_wrapper.c
+++ b/src/kadmin/cli/ss_wrapper.c
@@ -40,6 +40,7 @@ main(int argc, char *argv[])
int sci_idx, code = 0;

setlocale(LC_MESSAGES, "");
+ setlocale(LC_TIME, "");
whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]);

request = kadmin_startup(argc, argv);
Date: Thu, 5 Jul 2012 16:44:43 -0400 (EDT)
From: Benjamin Kaduk <kaduk@MIT.EDU>
To: Sam Hartman via RT <rt-comment@krbdev.MIT.EDU>
CC: ";"@MIT.EDU, "'AdminCc of krbdev.mit.edu Ticket #7192'"@MIT.EDU
Subject: Re: [krbdev.mit.edu #7192] klist does not use localized time formatting
RT-Send-Cc:
On Thu, 5 Jul 2012, Sam Hartman via RT wrote:

Show quoted text
> Here's the patch we're using in Debian for this:
> I was planning on submitting after it made it into a Debian release:

Thanks, Sam.
Greg and I had talked about this some, and we were planning to change the
calls in all the clients from setlocale(LC_MESSAGES, "") to
setlocale(LC_ALL, ""), since we believe that this should be safe.
(If anything is going on the wire that is subjet to localization, that is
a bug.) This has the advantage of keeping everything consistent, and we
can run the test suite with LC_ALL=C as well.

-Ben
From: kaduk@MIT.EDU
Subject: SVN Commit
Download (untitled) / with headers
text/plain 1.9KiB

Enable all localizations in main functions

Bite the bullet and pass LC_ALL to setlocale() instead of just
LC_MESSAGES. Calls to setlocale() itself were introduced in
fabbf9e443459e8c0161c84563690ed70c7f6a61 for ticket 6918, but
only for LC_MESSAGES since only localized strings were needed
and that was the most conservative option.
However, klist, kadmin, and kinit (and perhaps others) would benefit
from localized formats for times (i.e., LC_TIME). If potentially
localized data is being sent on the wire, that is a bug that should
be fixed. No such bugs are found with the current test suite, so we
are comfortable enabling LC_ALL at this time.

https://github.com/krb5/krb5/commit/75c7c600b49a7f1d5cf95260fc073cb4ba5929cd
Author: Ben Kaduk <kaduk@mit.edu>
Commit: 75c7c600b49a7f1d5cf95260fc073cb4ba5929cd
Branch: master
src/clients/kdestroy/kdestroy.c | 2 +-
src/clients/kinit/kinit.c | 2 +-
src/clients/klist/klist.c | 2 +-
src/clients/kpasswd/kpasswd.c | 2 +-
src/clients/kswitch/kswitch.c | 2 +-
src/clients/kvno/kvno.c | 2 +-
src/kadmin/cli/ss_wrapper.c | 2 +-
src/kadmin/dbutil/kdb5_util.c | 2 +-
src/kadmin/ktutil/ktutil.c | 2 +-
src/kadmin/server/ovsec_kadmd.c | 2 +-
src/kadmin/testing/scripts/env-setup.shin | 5 +++--
src/kdc/main.c | 2 +-
src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c | 2 +-
src/slave/kprop.c | 2 +-
src/slave/kpropd.c | 2 +-
src/slave/kproplog.c | 2 +-
src/tests/dejagnu/config/default.exp | 7 ++++---
src/tests/misc/test_chpw_message.c | 2 +-
src/util/k5test.py | 5 +++--
19 files changed, 26 insertions(+), 23 deletions(-)
[kaduk@MIT.EDU - Fri Jul 6 14:07:50 2012]:

Show quoted text
>
> Enable all localizations in main functions
>
> Bite the bullet and pass LC_ALL to setlocale() instead of just
> LC_MESSAGES. Calls to setlocale() itself were introduced in
> fabbf9e443459e8c0161c84563690ed70c7f6a61 for ticket 6918, but
> only for LC_MESSAGES since only localized strings were needed
> and that was the most conservative option.
> However, klist, kadmin, and kinit (and perhaps others) would benefit
> from localized formats for times (i.e., LC_TIME). If potentially
> localized data is being sent on the wire, that is a bug that should
> be fixed. No such bugs are found with the current test suite, so we
> are comfortable enabling LC_ALL at this time.

The patch changes the test suite to force LC_ALL=C, so it is
unsurprising that the tests still pass when the user running 'make
check' has alternate locale settings.
As an additional and more useful check, I altered the tests to only
force LC_MESSAGES=C, and ran the test suite with
LC_{TIME,NUMERIC,COLLATE,CTYPE,MONETARY} set to both fr_FR.UTF-8 and
zh_CN.UTF-8; the tests still passed.