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

(-)coreutils-5.2.1/src/su.c (-1 / +9 lines)
Lines 554-559 Link Here
554
modify_environment (const struct passwd *pw, const char *shell)
554
modify_environment (const struct passwd *pw, const char *shell)
555
{
555
{
556
  char *term;
556
  char *term;
557
  char *display;
558
  char *xauthority;
557
559
558
#ifdef USE_PAM
560
#ifdef USE_PAM
559
  /* Export env variables declared by PAM modules */
561
  /* Export env variables declared by PAM modules */
Lines 571-583 Link Here
571
573
572
  if (simulate_login)
574
  if (simulate_login)
573
    {
575
    {
574
      /* Leave TERM unchanged.  Set HOME, SHELL, USER, LOGNAME, PATH.
576
      /* Leave TERM, DISPLAY, XAUTHORITY unchanged.  Set HOME, SHELL, USER, LOGNAME, PATH.
575
         Unset all other environment variables.  */
577
         Unset all other environment variables.  */
576
      term = getenv ("TERM");
578
      term = getenv ("TERM");
579
      display = getenv ("DISPLAY");
580
      xauthority = getenv ("XAUTHORITY");
577
      environ = xmalloc (2 * sizeof (char *));
581
      environ = xmalloc (2 * sizeof (char *));
578
      environ[0] = 0;
582
      environ[0] = 0;
579
      if (term)
583
      if (term)
580
	xputenv (concat ("TERM", "=", term));
584
	xputenv (concat ("TERM", "=", term));
585
      if (display)
586
	xputenv (concat ("DISPLAY", "=", display));
587
      if (xauthority)
588
	xputenv (concat ("XAUTHORITY", "=", xauthority));
581
      xputenv (concat ("HOME", "=", pw->pw_dir));
589
      xputenv (concat ("HOME", "=", pw->pw_dir));
582
      xputenv (concat ("SHELL", "=", shell));
590
      xputenv (concat ("SHELL", "=", shell));
583
      xputenv (concat ("USER", "=", pw->pw_name));
591
      xputenv (concat ("USER", "=", pw->pw_name));

Return to bug 57238