diff --git a/src/session-child.c b/src/session-child.c index 4e04137d..c6353759 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -398,10 +398,14 @@ session_child_run (int argc, char **argv) { /* Set POSIX variables */ pam_putenv (pam_handle, "PATH=/usr/local/bin:/usr/bin:/bin"); - pam_putenv (pam_handle, g_strdup_printf ("USER=%s", username)); - pam_putenv (pam_handle, g_strdup_printf ("LOGNAME=%s", username)); - pam_putenv (pam_handle, g_strdup_printf ("HOME=%s", user_get_home_directory (user))); - pam_putenv (pam_handle, g_strdup_printf ("SHELL=%s", user_get_shell (user))); + g_autofree char* user_env = g_strdup_printf ("USER=%s", username); + pam_putenv (pam_handle, user_env); + g_autofree char* logname_env = g_strdup_printf ("LOGNAME=%s", username); + pam_putenv (pam_handle, logname_env); + g_autofree char* home_env = g_strdup_printf ("HOME=%s",user_get_home_directory (user)); + pam_putenv (pam_handle, home_env); + g_autofree char* shell_env = g_strdup_printf ("SHELL=%s", user_get_shell (user)); + pam_putenv (pam_handle, shell_env); /* Let the greeter and user session inherit the system default locale */ static const gchar * const locale_var_names[] = {