From: Karel Zak Date: Thu, 16 Jan 2025 12:14:43 +0000 (+0100) Subject: sulogin: fix POSIX locale use X-Git-Tag: v2.42-start~86^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa11f9a2e163a57455255b03a03bf841cbf5be72;p=thirdparty%2Futil-linux.git sulogin: fix POSIX locale use In some cases, sulogin can set LC_CTYPE="POSIX" while retaining the original LC_MESSAGES. In this scenario, the gettext() function may not work as intended and sulogin returns "???" (for example for ja_JP.UTF-8). GNU gettext FAQ: This symptom occurs when the LC_CTYPE facet of the locale is not set; then gettext() doesn't know which character set to use, and converts all messages to ASCII, as far as possible. Addresses: https://issues.redhat.com/browse/RHEL-56983 Addresses: https://github.com/util-linux/util-linux/issues/2185 Signed-off-by: Karel Zak --- diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index d22413962..77fc5b20f 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -313,6 +313,7 @@ static void tcinit(struct console *con) } setlocale(LC_CTYPE, "POSIX"); + setlocale(LC_MESSAGES, "POSIX"); goto setattr; } #if defined(IUTF8) && defined(KDGKBMODE) @@ -327,10 +328,12 @@ static void tcinit(struct console *con) case K_XLATE: default: setlocale(LC_CTYPE, "POSIX"); + setlocale(LC_MESSAGES, "POSIX"); break; } #else setlocale(LC_CTYPE, "POSIX"); + setlocale(LC_MESSAGES, "POSIX"); #endif reset_virtual_console(tio, flags); setattr: