Skip to content

Commit 11c4a81

Browse files
liuyuanpeng176jrybar-rh
authored andcommitted
Before clearing the environment variables, save the language environment variable first, and then set it again after clearing the environment variables to solve the problem that the PAM messages are not translated.
1 parent 42d3c42 commit 11c4a81

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/polkitagent/polkitagenthelper-pam.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,21 @@ main (int argc, char *argv[])
8383
rc = 0;
8484
pam_h = NULL;
8585

86+
char *lang = getenv("LANG");
87+
char *language = getenv("LANGUAGE");
88+
8689
/* clear the entire environment to avoid attacks using with libraries honoring environment variables */
8790
if (_polkit_clearenv () != 0)
8891
goto error;
8992

9093
/* set a minimal environment */
9194
setenv ("PATH", "/usr/sbin:/usr/bin:/sbin:/bin", 1);
9295

96+
if(lang)
97+
setenv("LANG",lang,0);
98+
if(language)
99+
setenv("LANGUAGE",language,0);
100+
93101
/* check that we are setuid root */
94102
if (geteuid () != 0)
95103
{

0 commit comments

Comments
 (0)