1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-18 03:46:03 +00:00

Fix PAM bogons in xdm.

Submitted by:	des
This commit is contained in:
Jean-Marc Zucconi 2002-03-05 23:35:26 +00:00
parent 7b6630a8cd
commit 47009eab1c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=55603

View File

@ -1,27 +1,37 @@
--- programs/xdm/session.c.orig Wed May 30 00:56:22 2001 --- programs/xdm/session.c.orig Tue Feb 19 23:36:19 2002
+++ programs/xdm/session.c Fri Sep 28 23:25:16 2001 +++ programs/xdm/session.c Tue Feb 19 23:51:21 2002
@@ -541,6 +541,7 @@ @@ -573,11 +573,13 @@
int pid; #ifdef USE_PAM
#ifdef HAS_SETUSERCONTEXT /* pass in environment variables set by libpam and modules it called */
struct passwd* pwd; if (pamh) {
+ extern char **environ; - long i;
+ int i;
char **pam_env = pam_getenvlist(pamh);
for(i = 0; pam_env && pam_env[i]; i++) {
verify->userEnviron = putEnv(pam_env[i], verify->userEnviron);
+ free(pam_env[i]);
}
+ free(pam_env);
}
#endif #endif
#ifdef USE_PAM
pam_handle_t *pamh = thepamh(); @@ -623,12 +625,19 @@
@@ -623,6 +624,8 @@
* Set the user's credentials: uid, gid, groups,
* environment variables, resource limits, and umask.
*/
+ /* destroy user environment before calling setusercontext */
+ environ = verify->userEnviron;
pwd = getpwnam(name); pwd = getpwnam(name);
if (pwd) if (pwd)
{ {
@@ -632,6 +635,7 @@ + extern char **environ;
+ char **saved_environ = environ;
+
+ environ = verify->userEnviron;
if (setusercontext(NULL, pwd, pwd->pw_uid, LOGIN_SETALL) < 0)
{
+ environ = saved_environ;
LogError("setusercontext for \"%s\" failed, errno=%d\n", name,
errno); errno);
return (0); return (0);
} }
+ verify->userEnviron = environ; + verify->userEnviron = environ;
+ environ = saved_environ;
endpwent(); endpwent();
} }
else else