pam_begin_session(pw)
struct passwd *pw;
{
+#ifdef HAVE_PAM_GETENVLIST
+ char **pam_envp;
+#endif
int status = PAM_SUCCESS;
/*
*/
(void) pam_setcred(pamh, PAM_ESTABLISH_CRED);
+#ifdef HAVE_PAM_GETENVLIST
+ /*
+ * Update environment based on what is stored in pamh.
+ * If no authentication is done we will only have environment
+ * variables if pam_env is called via session.
+ */
+ if ((pam_envp = pam_getenvlist(pamh)) != NULL) {
+ /* Merge pam env with user env but do not overwrite. */
+ env_merge(pam_envp, FALSE);
+ efree(pam_envp);
+ /* XXX - we leak any duplicates that were in pam_envp */
+ }
+#endif /* HAVE_PAM_GETENVLIST */
+
#ifndef NO_PAM_SESSION
status = pam_open_session(pamh, 0);
if (status != PAM_SUCCESS) {
}
}
+/*
+ * Merge another environment with our private copy.
+ */
+void
+env_merge(char * const envp[], int overwrite)
+{
+ char * const *ep;
+
+ for (ep = envp; *ep != NULL; ep++)
+ sudo_putenv(*ep, TRUE, overwrite);
+}
+
/*
* Check the env_delete blacklist.
* Returns TRUE if the variable was found, else false.
/* env.c */
char **env_get __P((void));
void env_init __P((int lazy));
+void env_merge __P((char * const envp[], int overwrite));
void init_envtables __P((void));
void insert_env_vars __P((struct list_member *));
void read_env_file __P((const char *, int));