Skip to content

Commit

Permalink
Before clearing the environment variables, save the language environm…
Browse files Browse the repository at this point in the history
…ent variable first, and then set it again after clearing the environment variables to solve the problem that the PAM messages are not translated.
  • Loading branch information
liuyuanpeng176 authored and jrybar-rh committed Feb 13, 2025
1 parent 42d3c42 commit 11c4a81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/polkitagent/polkitagenthelper-pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ main (int argc, char *argv[])
rc = 0;
pam_h = NULL;

char *lang = getenv("LANG");
char *language = getenv("LANGUAGE");

/* clear the entire environment to avoid attacks using with libraries honoring environment variables */
if (_polkit_clearenv () != 0)
goto error;

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

if(lang)
setenv("LANG",lang,0);
if(language)
setenv("LANGUAGE",language,0);

/* check that we are setuid root */
if (geteuid () != 0)
{
Expand Down

0 comments on commit 11c4a81

Please sign in to comment.