From 53ddd6ca96a26e08b37b76bc4ec7477c83d8752e Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 29 Oct 2008 21:35:45 +0000 Subject: Properly set PAM enviornment variables after opening session. Without this change, modules like pam_mktemp or pam_env and similar will be unable to change users' environments, like they are supposed to. --- src/rc/start-stop-daemon.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 463983e4..de5bd1dc 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -563,6 +563,7 @@ int start_stop_daemon(int argc, char **argv) #ifdef HAVE_PAM pam_handle_t *pamh = NULL; int pamr; + const char *const *pamenv = NULL; #endif int opt; @@ -1026,6 +1027,19 @@ int start_stop_daemon(int argc, char **argv) i = 0; while(environ[i]) rc_stringlist_add(env_list, environ[i++]); + +#ifdef HAVE_PAM + pamenv = (const char *const *)pam_getenvlist(pamh); + if (pamenv) { + while (*pamenv) { + /* Don't add strings unless they set a var */ + if (strchr(*pamenv, '=')) + putenv(xstrdup(*pamenv)); + pamenv++; + } + } +#endif + TAILQ_FOREACH(env, env_list, entries) { if ((strncmp(env->value, "RC_", 3) == 0 && strncmp(env->value, "RC_SERVICE=", 10) != 0 && -- cgit v1.2.3