summaryrefslogtreecommitdiff
path: root/modules/pam_xauth/pam_xauth.c
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2005-03-14 09:42:27 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2005-03-14 09:42:27 +0000
commit2324e72d69927a7d2b6c8c67d641d35066484474 (patch)
treecabd7d243f61952e1131b148ee776398a9abf82d /modules/pam_xauth/pam_xauth.c
parent4e5a337d397e46f65a4704014d8434c22497588c (diff)
Relevant BUGIDs: Novell #66885
Purpose of commit: bugfix Commit summary: --------------- DISPLAY variable was not preserved, which means that pam_xauth only works if the calling application takes care of it.
Diffstat (limited to 'modules/pam_xauth/pam_xauth.c')
-rw-r--r--modules/pam_xauth/pam_xauth.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/modules/pam_xauth/pam_xauth.c b/modules/pam_xauth/pam_xauth.c
index bde432e2..700edbd3 100644
--- a/modules/pam_xauth/pam_xauth.c
+++ b/modules/pam_xauth/pam_xauth.c
@@ -542,13 +542,33 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
}
/* Unset any old XAUTHORITY variable in the environment. */
- if (getenv(XAUTHENV)) {
- unsetenv(XAUTHENV);
- }
+ if (getenv (XAUTHENV))
+ unsetenv (XAUTHENV);
/* Set the new variable in the environment. */
- pam_putenv(pamh, xauthority);
- putenv(xauthority); /* The environment owns this string now. */
+ if (pam_putenv (pamh, xauthority) != PAM_SUCCESS)
+ syslog (LOG_DEBUG, "pam_xauth: can't set environment variable '%s'",
+ xauthority);
+ putenv (xauthority); /* The environment owns this string now. */
+
+ /* set $DISPLAY in pam handle to make su - work */
+ {
+ char *d = (char *) malloc (strlen ("DISPLAY=") +
+ strlen (display) + 1);
+ if (d == NULL)
+ {
+ syslog (LOG_DEBUG, "pam_xauth: memory exhausted\n");
+ return PAM_SESSION_ERR;
+ }
+ strcpy (d, "DISPLAY=");
+ strcat (d, display);
+
+ if (pam_putenv (pamh, d) != PAM_SUCCESS)
+ syslog (LOG_DEBUG,
+ "pam_xauth: can't set environment variable '%s'",
+ d);
+ free (d);
+ }
/* Merge the cookie we read before into the new file. */
if (debug) {