[comp.protocols.kerberos] nasty interaction between login.krb and setenv

greg%duke.cs.unlv.edu@RELAY.CS.NET (Greg Wohletz) (08/27/90)

Due to the way the setenv routine is implemented once you have called
setenv, and further values assigned to environ must be obtained through
malloc.  The following diff will keep login.krb from dumping core when
not run with the -p option.

*** login.c.athena	Tue Aug 14 13:53:54 1990
--- login.c	Sun Aug 26 18:22:24 1990
***************
*** 169,177 ****
  	int kflag, Kflag, eflag;
  	int quietlog, passwd_req, ioctlval;
  	sigtype timedout();
! 	char *domain, *salt, *envinit[1], *ttyn, *tty;
  	char tbuf[MAXPATHLEN + 2];
! 	char *ttyname(), *stypeof(), *crypt(), *getpass();
  	time_t time();
  	off_t lseek();
  
--- 169,177 ----
  	int kflag, Kflag, eflag;
  	int quietlog, passwd_req, ioctlval;
  	sigtype timedout();
! 	char *domain, *salt, *ttyn, *tty;
  	char tbuf[MAXPATHLEN + 2];
! 	char *ttyname(), *stypeof(), *crypt(), *getpass(), *malloc();
  	time_t time();
  	off_t lseek();
  
***************
*** 600,607 ****
  	}
  
  	/* destroy environment unless user has requested preservation */
! 	if (!pflag)
! 		environ = envinit;
  	(void)setenv("HOME", pwd->pw_dir, 1);
  	(void)setenv("SHELL", pwd->pw_shell, 1);
  	if (term[0] == '\0')
--- 600,609 ----
  	}
  
  	/* destroy environment unless user has requested preservation */
! 	if (!pflag) {
! 		environ = (char **) malloc(sizeof(char *)); /* must be allocated by malloc! */
! 		environ[0] = NULL; 
! 	}
  	(void)setenv("HOME", pwd->pw_dir, 1);
  	(void)setenv("SHELL", pwd->pw_shell, 1);
  	if (term[0] == '\0')