Client localization design issues

Ken Raeburn raeburn at MIT.EDU
Thu Jun 2 23:32:55 EDT 2011


On May 20, 2011, at 10:54, Sam Hartman wrote:
> I suspect we could convince Ted Ts'o to accept a atch to e2fsprogs to
> call gettext if we could figure out a solution to the domain issue.  If
> this can be made to work it seems cleanest.

Since -- at least in theory -- you could have a program using Kerberos and also providing its own error tables installed elsewhere, or using a second library that does, I'd suggest keeping the domain attached to the specific error tables.  (Whether it's coded into the .et file somehow, or passed by the library/application to the initialization routine, probably doesn't matter; I think we're going to lose in any case if the init call is done from an application referring directly to an independently installed library's tables.)  Then error_message can determine from the table id which domain to pass to dgettext so that it can find the correct set of message catalogs.  The krb5 (or other) library would need to call bindtextdomain before it could get translated messages out, but if it's generating any other messages, it presumably needs to do that anyways; that's probably an argument for passing the name in with the initialization call, so it can be maintained in one place.

Perhaps using an alternate initialization function, which accepts a domain string argument.  There's currently no versioning of the internal data structures, so altering the existing error table format would be a backward-incompatible change, though it's not clear that that's broken -- do the binary error tables used on a system have to be in sync with the system com_err library and associated tools, or not?  Can we rule out having a .c file generated by one version calling into a different library?

Based on how we do (AFAIK) use the native compile_et if configured that way, I'd suggest doing something like:

  #ifdef HAVE_WEAK_REFS
  #pragma weak initialize_foo_error_table_l
  if (&initialize_foo_error_table_l == NULL)
    initialize_foo_error_table();
  else
  #endif
    initialize_foo_error_table_l("mit-krb5");
  bindtextdomain("mit-krb5", MY_CATALOG_DIR);

and just insist on any of: weak references are supported, *or* the built-in com_err code (which would generate the alternate "_l" function, optionally with another weak-ref check for "add_error_table_l", depending of what mix-and-match modes you might want to support) is used, *or* the system one has been upgraded compatibly.  I doubt many systems both have old com_err libraries separate from Kerberos as port of the OS and do not support weak references.


As to whether error_message or its caller should do the mapping, I'll point out a couple of things:

 * com_err prints out the string that error_message would return, and it probably should output a locale-dependent message

 * error_message can return strings from strerror when given a system error code, and strerror is supposed to give you locale-dependent strings (http://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html), so in certain cases you should *already* get the translated messages back

so I really do think error_message should be doing it.

Ken



More information about the krbdev mailing list