View | Details | Raw Unified | Return to bug 57238
Collapse All | Expand All

(-)Linux-PAM-0.77/modules/pam_xauth/pam_xauth.c (-2 / +17 lines)
Lines 59-64 Link Here
59
#define DATANAME "pam_xauth_cookie_file"
59
#define DATANAME "pam_xauth_cookie_file"
60
#define XAUTHBIN "/usr/X11R6/bin/xauth"
60
#define XAUTHBIN "/usr/X11R6/bin/xauth"
61
#define XAUTHENV "XAUTHORITY"
61
#define XAUTHENV "XAUTHORITY"
62
#define DISPLAYENV "DISPLAY"
62
#define HOMEENV  "HOME"
63
#define HOMEENV  "HOME"
63
#define XAUTHDEF ".Xauthority"
64
#define XAUTHDEF ".Xauthority"
64
#define XAUTHTMP ".xauthXXXXXX"
65
#define XAUTHTMP ".xauthXXXXXX"
Lines 271-277 Link Here
271
pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
272
pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
272
{
273
{
273
	char xauthpath[] = XAUTHBIN;
274
	char xauthpath[] = XAUTHBIN;
274
	char *cookiefile = NULL, *xauthority = NULL,
275
	char *cookiefile = NULL, *xauthority = NULL, *d = NULL,
275
	     *cookie = NULL, *display = NULL, *tmp = NULL;
276
	     *cookie = NULL, *display = NULL, *tmp = NULL;
276
	const char *user, *xauth = xauthpath;
277
	const char *user, *xauth = xauthpath;
277
	struct passwd *tpwd, *rpwd;
278
	struct passwd *tpwd, *rpwd;
Lines 314-325 Link Here
314
	}
315
	}
315
316
316
	/* If DISPLAY isn't set, we don't really care, now do we? */
317
	/* If DISPLAY isn't set, we don't really care, now do we? */
317
	if ((display = getenv("DISPLAY")) == NULL) {
318
	if ((display = getenv(DISPLAYENV)) == NULL) {
318
		if (debug) {
319
		if (debug) {
319
			syslog(LOG_DEBUG, "pam_xauth: user has no DISPLAY,"
320
			syslog(LOG_DEBUG, "pam_xauth: user has no DISPLAY,"
320
			       " doing nothing");
321
			       " doing nothing");
321
		}
322
		}
322
		return PAM_SUCCESS;
323
		return PAM_SUCCESS;
324
	} else {
325
		/* But if it is, we need to make sure it gets copied. */
326
                d = malloc(strlen(DISPLAYENV) + 1 +
327
                           strlen(display) + 1);
328
                                                                                                                                                             
329
                strcpy(d, DISPLAYENV);
330
                strcat(d, "=");
331
                strcat(d, display);
323
	}
332
	}
324
333
325
	/* Read the target user's name. */
334
	/* Read the target user's name. */
Lines 550-555 Link Here
550
		pam_putenv(pamh, xauthority);
559
		pam_putenv(pamh, xauthority);
551
		putenv(xauthority); /* The environment owns this string now. */
560
		putenv(xauthority); /* The environment owns this string now. */
552
561
562
563
		/* Now is a good time to put the copied DISPLAY environment too. */
564
		unsetenv(DISPLAYENV);
565
		pam_putenv(pamh, d);
566
		putenv(d);
567
553
		/* Merge the cookie we read before into the new file. */
568
		/* Merge the cookie we read before into the new file. */
554
		if (debug) {
569
		if (debug) {
555
			syslog(LOG_DEBUG, "pam_xauth: writing key `%s' to "
570
			syslog(LOG_DEBUG, "pam_xauth: writing key `%s' to "

Return to bug 57238