Skip to content

Conversation

@liaohanqin
Copy link

pam message with error language env.

@github-actions
Copy link

Hey! undefined has not signed the Canonical CLA which is required to get this contribution merged on this project.

Please head over to https://ubuntu.com/legal/contributors to read more about it.

@liaohanqin liaohanqin mentioned this pull request Jan 17, 2022
@robert-ancell
Copy link
Collaborator

What problem is this PR solving? Should the PAM conversation not inherit the system locale?

@thiagoneo
Copy link

Wow, I applied this patch and it really solved the problem of lightdm not showing the PAM messages in the correct locale. Canonical should merge this ...

@lo1ol
Copy link

lo1ol commented Mar 19, 2025

What problem is this PR solving? Should the PAM conversation not inherit the system locale?

Pam modules not inherit system locale. Pam application should set it explicitly. Actually applications don't use system locale on startup. If you don't call setlocale(LC_ALL, "") the default locale will be "C":

On startup of the main program, the portable "C" locale is
selected as default. A program may be made portable to all
locales by calling:
setlocale(LC_ALL, "");

System and parent's process locale don't matter

cat > main.c << EOF
#include <stdio.h>
#include <libintl.h>
#include <locale.h>
#include <stdlib.h>

int main() {
   printf("%s\n", dgettext("Linux-PAM", "Password: "));
   setlocale(LC_ALL, "");
   printf("%s\n", dgettext("Linux-PAM", "Password: "));
   system("./main2");
}
EOF

cat > main2.c << EOF
#include <stdio.h>
#include <libintl.h>
#include <locale.h>

int main() {
   printf("%s\n", dgettext("Linux-PAM", "Password: "));
}
EOF

gcc main.c -o main
gcc main2.c -o main2

LANG=ru_RU.UTF-8 ./main

My output is:

Password: 
Пароль: 
Password: 

So, this change really helps.

I think PR's author abandoned it. If you have no time to support it, I could

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants