[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] Export PAM environment to shell
From:       Ryan Phillips <ryan () trolocsis ! com>
Date:       2011-03-31 17:03:30
Message-ID: 20110331170330.GB8929 () hera ! xen ! prgmr ! com
[Download RAW message or body]

Denys Vlasenko <vda.linux@googlemail.com> said:
> On Thu, Mar 31, 2011 at 1:00 AM, Ryan Phillips <ryan@trolocsis.com> wrote:
> > Denys Vlasenko <vda.linux@googlemail.com> said:
> >> On Tuesday 15 March 2011 16:28, Ryan Phillips wrote:
> >> > Hi!
> >> >
> >> > Here is a patch to export the PAM environment to the shell. This patch is needed
> >> > for certain PAM modules that manipulate environment variables.
> >>
> >> Since you only need to do it in login, can you put necessary
> >> code in login.c, instead of touching so many other files too?
> >
> > Denys,
> >
> > The function that is called is a shared API call to other applications. IIRC,
> > the modified function does a clearenv() so I believe this modification will need
> > an API change.
> 
> I don't understand your explanation.
> 

Ah, I see your point. Here is a revised patch.

Thanks,
Ryan

["0001-pam-environment.diff" (text/x-diff)]

diff --git a/loginutils/login.c b/loginutils/login.c
index 9a624df..34d1905 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -210,6 +210,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
 	char *opt_user = opt_user; /* for compiler */
 	char *full_tty;
 	IF_SELINUX(security_context_t user_sid = NULL;)
+	char **pam_envlist = NULL;
 #if ENABLE_PAM
 	int pamret;
 	pam_handle_t *pamh;
@@ -324,6 +325,10 @@ int login_main(int argc UNUSED_PARAM, char **argv)
 			failed_msg = "setcred";
 			goto pam_auth_failed;
 		}
+
+		/* Get PAM environment */
+		pam_envlist = pam_getenvlist(pamh);
+
 		break; /* success, continue login process */
 
  pam_auth_failed:
@@ -400,6 +405,13 @@ int login_main(int argc UNUSED_PARAM, char **argv)
 			(!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV,
 			pw);
 
+	if (pam_envlist) {
+		int i;
+		for (i=0; pam_envlist[i] != NULL; i++) {
+			putenv(pam_envlist[i]);
+		}
+	}
+
 	motd();
 
 	if (pw->pw_uid == 0)


_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic