pkexec: Set process environment from pam_getenvlist()
authorSteve Langasek <steve.langasek@canonical.com>
Fri, 8 Mar 2013 11:00:00 +0000 (12:00 +0100)
committerColin Walters <walters@verbum.org>
Thu, 11 Apr 2013 17:30:49 +0000 (13:30 -0400)
Various pam modules provide environment variables that are intended to be set
in the environment of the pam session.  pkexec needs to process the output of
pam_getenvlist() to get these.

https://bugs.freedesktop.org/show_bug.cgi?id=62016

src/programs/pkexec.c

index f42a3bb..529898a 100644 (file)
@@ -145,6 +145,7 @@ open_session (const gchar *user_to_auth)
   gboolean ret;
   gint rc;
   pam_handle_t *pam_h;
+  char **envlist;
   struct pam_conv conversation;
 
   ret = FALSE;
@@ -176,6 +177,15 @@ open_session (const gchar *user_to_auth)
 
   ret = TRUE;
 
+  envlist = pam_getenvlist (pam_h);
+  if (envlist != NULL)
+    {
+      guint n;
+      for (n = 0; envlist[n]; n++)
+        putenv (envlist[n]);
+      free (envlist);
+    }
+
 out:
   if (pam_h != NULL)
     pam_end (pam_h, rc);