[5971] in Kerberos

home help back first fref pref prev next nref lref last post

Kerberos 5 beta 5 and IRIX 5.3

daemon@ATHENA.MIT.EDU (Douglas Engert)
Sun Oct 8 17:10:34 1995

To: krb5-bugs@MIT.EDU
Cc: kerberos@MIT.EDU, authtf@es.net
Date: Sun, 08 Oct 1995 15:58:57 -0500
From: Douglas Engert <b17783@achilles.ctd.anl.gov>

I would like to report the folowing bugs in the4 Kerberos 5 beta 5 code when
running on a SGI system with IRIX 5.3:		

 o The configure in appl/bsd fails to detect the STREAMS. I have manually
added -DHAVE_STREAMS to the options to compensate for this.

 o With STREAMS, the telnet/telnetd/sys_term.c tries to push the ttcompat
routine, but gets an error. This apparently is not available on the SGI. 

 o The above is also true when using STREAMS in the krlogind.c code as well

 o The krlogind.c needs some of the code from sys_term.c to get the
controlling terminal. This is done similiar to the telnet sys_term.c. 

 o appl/bsd/logutil.c does not test for a NULL host entry in some cases.
This bug was found by (Paul D Gjefle) pd_gjefle@pnl.gov. 

FYI, I am using gcc 2.6.3, and have tested the following changes on
IRIX 5.3, Solaris 2.4 and SunOS 4.1.3.

Attached is a context diff file for the modules meantioned above. I complete
context diff file can be found at:
 ftp://achilles.ctd.anl.gov/pub/kerberos.v5/k55.cdiff.951008


           Douglas E. Engert
           Systems Programming
           Argonne National Laboratory
           9700 South Cass Avenue
           Argonne, Illinois  60439
           (708) 252-5444

           Internet: DEEngert@anl.gov                                          

*** appl/bsd/,logutil.c	Wed Apr 26 16:44:19 1995
--- appl/bsd/logutil.c	Sun Oct  8 11:05:50 1995
***************
*** 124,129 ****
--- 124,135 ----
  #ifdef HAVE_SETUTXENT
      setutxent();
      getutmpx(ent, &utx);
+ #ifndef NO_UT_HOST
+     if (host)
+ 		strncpy(utx.ut_host, host, sizeof(utx.ut_host));
+ 	else
+ 		strncpy(utx.ut_host, "", sizeof(utx.ut_host));
+ #endif
      pututxline(&utx);
      endutxent();
  #endif /* HAVE_SETUTXENT */
***************
*** 139,149 ****
  
  #endif /* HAVE_SETUTENT */
  
!     update_wtmp(ent);
  }
  
! void update_wtmp(ent)
      struct utmp *ent;
  {
      struct utmp ut;
      struct stat statb;
--- 145,156 ----
  
  #endif /* HAVE_SETUTENT */
  
!     update_wtmp(ent, host);
  }
  
! void update_wtmp(ent, host)
      struct utmp *ent;
+ 	char *host;
  {
      struct utmp ut;
      struct stat statb;
***************
*** 152,162 ****
--- 159,180 ----
      struct utmpx utx;
  
      getutmpx(ent, &utx);
+ #ifndef NO_UT_HOST
+ 	if (host)
+ 		strncpy(utx.ut_host, host, sizeof(utx.ut_host));
+ 	else
+ 		strncpy(utx.ut_host, "", sizeof(utx.ut_host));
+ #endif
      updwtmpx(WTMPX_FILE, &utx);
  #endif
  
  #ifdef HAVE_UPDWTMP
+ #ifndef HAVE_SETUTXENT
+ 	/**  This operation is already done by updwtmpx()
+ 	***  when HAVE_SETUTXENT is defined.
+ 	**/
      updwtmp(WTMP_FILE, ent);
+ #endif
  #else /* HAVE_UPDWTMP */
  
      if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) >= 0) {
***************
*** 201,207 ****
  
  
  #ifndef NO_UT_HOST
!     strncpy(ut.ut_host, host, sizeof(ut.ut_host));
  #endif
  
      strncpy(ut.ut_line, tty, sizeof(ut.ut_line));
--- 219,228 ----
  
  
  #ifndef NO_UT_HOST
! 	if (host)
!     	strncpy(ut.ut_host, host, sizeof(ut.ut_host));
! 	else
! 		strncpy(ut.ut_host, "", sizeof(ut.ut_host));
  #endif
  
      strncpy(ut.ut_line, tty, sizeof(ut.ut_line));
***************
*** 220,225 ****
      strncpy(ut.ut_name, locuser, sizeof(ut.ut_name));
  #endif
  
!     update_wtmp(&ut);
  }
  #endif
--- 241,246 ----
      strncpy(ut.ut_name, locuser, sizeof(ut.ut_name));
  #endif
  
!     update_wtmp(&ut, host);
  }
  #endif
*** appl/bsd/,krlogind.c	Wed May  3 02:46:06 1995
--- appl/bsd/krlogind.c	Sun Oct  8 07:49:06 1995
***************
*** 99,104 ****
--- 99,105 ----
   */
  #define LOG_REMOTE_REALM
  #define CRYPT
+ #define LOG_ALL_LOGINS
  
  
  #ifdef HAVE_UNISTD_H
***************
*** 624,640 ****
      (void) setsid();
  #endif
  
! #ifdef ultrix
      /* The Ultrix (and other BSD tty drivers) require the process group
       * to be zero, in order to acquire the new tty as a controlling tty. */
      (void) setpgrp(0, 0);
  #endif
  
!     t = open(line, O_RDWR);
      if (t < 0)
        fatalperror(f, line);
  
! #ifdef ultrix
      setpgrp(0, getpid());
  #endif
  	
--- 625,645 ----
      (void) setsid();
  #endif
  
! #if defined(ultrix) || defined(_AIX) || defined(SYSV) 
      /* The Ultrix (and other BSD tty drivers) require the process group
       * to be zero, in order to acquire the new tty as a controlling tty. */
+ #ifdef SETPGRP_TWOARGS
      (void) setpgrp(0, 0);
+ #else
+ 	(void) setpgrp();
  #endif
+ #endif
  
!     t = open(line, O_RDWR|O_NOCTTY);
      if (t < 0)
        fatalperror(f, line);
  
! #ifdef ultrix 
      setpgrp(0, getpid());
  #endif
  	
***************
*** 671,688 ****
  	if (line_push(t) < 0)
  	  fatalperror(f, "IPUSH");
  #else
! #ifdef sun
  	while (ioctl (t, I_POP, 0) == 0); /*Clear out any old lined's*/
  	if (ioctl(t, I_PUSH, "ptem") < 0)
  	  fatalperror(f, "IPUSH-ptem");
  	if (ioctl(t, I_PUSH, "ldterm") < 0)
  	  fatalperror(f, "IPUSH-ldterm");
  	if (ioctl(t, I_PUSH, "ttcompat") < 0)
  	  fatalperror(f, "IPUSH-ttcompat");
  #endif /* sun */
  #endif /* HAVE_LINE_PUSH */
  #endif /* HAVE_STREAMS */
  	
  	/*
  	 * Under Ultrix 3.0, the pgrp of the slave pty terminal
  	 * needs to be set explicitly.  Why rlogind works at all
--- 676,714 ----
  	if (line_push(t) < 0)
  	  fatalperror(f, "IPUSH");
  #else
! #if defined(sun) || defined(__sgi__)
  	while (ioctl (t, I_POP, 0) == 0); /*Clear out any old lined's*/
  	if (ioctl(t, I_PUSH, "ptem") < 0)
  	  fatalperror(f, "IPUSH-ptem");
  	if (ioctl(t, I_PUSH, "ldterm") < 0)
  	  fatalperror(f, "IPUSH-ldterm");
+ #ifndef __sgi__
  	if (ioctl(t, I_PUSH, "ttcompat") < 0)
  	  fatalperror(f, "IPUSH-ttcompat");
+ #endif
  #endif /* sun */
  #endif /* HAVE_LINE_PUSH */
  #endif /* HAVE_STREAMS */
  	
+  /* Need to have the child as the session leader and have the
+   * the terminal controled by this session. 
+   * so we will do what the login_tty routine in telnetd does.
+   *  DEE - 10/7/95
+   */
+ #if defined(HAVE_SETSID) && defined(HAVE_STREAMS)
+ 	if (setsid() < 0) {
+ #ifdef ultrix
+ 		 if ((setpgrp(0, 0) < 0) || (setsid() < 0))
+ #endif
+ 	 		fatalperror(f, "setsid()");
+ 	}
+ 	/* Get controlling tty assigned as side-effect of 
+ 	 * opening up a tty device. 
+ 	 */
+     (void) setpgrp(0, 0);
+  	close(open(line, O_RDWR));
+ #endif /*  HAVE_SETSID */
+ 
  	/*
  	 * Under Ultrix 3.0, the pgrp of the slave pty terminal
  	 * needs to be set explicitly.  Why rlogind works at all
***************
*** 903,911 ****
--- 929,939 ----
      w.ws_xpixel = ntohs(w.ws_xpixel);
      w.ws_ypixel = ntohs(w.ws_ypixel);
      (void)ioctl(pty, TIOCSWINSZ, &w);
+ #ifdef TIOCGPGRP
      if (ioctl(pty, TIOCGPGRP, &pgrp) >= 0)
        (void) killpg(pgrp, SIGWINCH);
  #endif
+ #endif
      return (4+sizeof (w));
  }
  
***************
*** 1429,1439 ****
  	if (grantpt(*fd) || unlockpt(*fd)) return 1;
  #endif
      
! #ifdef	HAVE_TTYNAME
! 	p = ttyname(*fd);
! #else
! #ifdef HAVE_PTSNAME
  	p = ptsname(*fd);
  #else
  	/* XXX If we don't have either what do we do */
  #endif
--- 1457,1467 ----
  	if (grantpt(*fd) || unlockpt(*fd)) return 1;
  #endif
      
! #ifdef	HAVE_PTSNAME
  	p = ptsname(*fd);
+ #else
+ #ifdef HAVE_TTYNAME
+ 	p = ttyname(*fd);
  #else
  	/* XXX If we don't have either what do we do */
  #endif
*** appl/bsd/,login.c	Fri Apr 28 19:36:13 1995
--- appl/bsd/login.c	Fri Oct  6 08:54:53 1995
***************
*** 254,259 ****
--- 254,260 ----
  	char *ttyname(), *stypeof(), *crypt(), *getpass();
  	time_t login_time;
  	off_t lseek();
+ 	char *ccname = 0;
  #ifdef POSIX_TERMIOS
  	struct termios tc;
  #endif
***************
*** 395,409 ****
  	if (*argv)
  		username = *argv;
  
! #if !defined(_AIX)
  	ioctlval = 0;
  #ifdef TIOCLSET
  	/* linux, sco don't have this line discipline interface */
  	(void)ioctl(0, TIOCLSET, (char *)&ioctlval);
  #endif
  	(void)ioctl(0, TIOCNXCL, (char *)0);
  	(void)fcntl(0, F_SETFL, ioctlval);
  #endif
  
  #ifdef POSIX_TERMIOS
  	(void)tcgetattr(0, &tc);
--- 396,414 ----
  	if (*argv)
  		username = *argv;
  
! #ifndef POSIX_TERMIOS
! #if !defined(_AIX) 
  	ioctlval = 0;
  #ifdef TIOCLSET
  	/* linux, sco don't have this line discipline interface */
  	(void)ioctl(0, TIOCLSET, (char *)&ioctlval);
  #endif
+ #ifdef TIOCNXCL
  	(void)ioctl(0, TIOCNXCL, (char *)0);
+ #endif
  	(void)fcntl(0, F_SETFL, ioctlval);
  #endif
+ #endif
  
  #ifdef POSIX_TERMIOS
  	(void)tcgetattr(0, &tc);
***************
*** 517,523 ****
  #endif
  		int read_long_pw_string();
  #endif /* KRB4 */
! #if !defined(_IBMR2)
  		ioctlval = 0;
  		(void)ioctl(0, TIOCSETD, (char *)&ioctlval);
  #endif
--- 522,528 ----
  #endif
  		int read_long_pw_string();
  #endif /* KRB4 */
! #if defined(NTTYDISC) && !defined(_IBMR2) && !defined(__sgi__)
  		ioctlval = 0;
  		(void)ioctl(0, TIOCSETD, (char *)&ioctlval);
  #endif
***************
*** 827,833 ****
  
  	if (*pwd->pw_shell == '\0')
  		pwd->pw_shell = BSHELL;
! #if defined(NTTYDISC) && !defined(_IBMR2)
  	/* turn on new line discipline for the csh */
  	else if (!strcmp(pwd->pw_shell, "/bin/csh")) {
  		ioctlval = NTTYDISC;
--- 832,838 ----
  
  	if (*pwd->pw_shell == '\0')
  		pwd->pw_shell = BSHELL;
! #if defined(NTTYDISC) && !defined(_IBMR2) && !defined(__sgi__)
  	/* turn on new line discipline for the csh */
  	else if (!strcmp(pwd->pw_shell, "/bin/csh")) {
  		ioctlval = NTTYDISC;
***************
*** 834,839 ****
--- 839,845 ----
  		(void)ioctl(0, TIOCSETD, (char *)&ioctlval);
  	}
  #endif
+     ccname = getenv("KRB5CCNAME");  /* save cache */
  
  	/* destroy environment unless user has requested preservation */
  	envinit = (char **)malloc(MAXENVIRON * sizeof(char *));
***************
*** 871,880 ****
--- 877,890 ----
  
  	envinit[i++] = NULL;
  
+ 	if (ccname)
+ 		setenv("KRB5CCNAME", ccname, 0);
+ 
  	setenv("HOME", pwd->pw_dir, 0);
  	setenv("PATH", LPATH, 0);
  	setenv("USER", pwd->pw_name, 0);
  	setenv("SHELL", pwd->pw_shell, 0);
+ 	setenv("LOGNAME", pwd->pw_name, 0);
  
  	if (term[0] == '\0')
  		(void) strncpy(term, stypeof(tty), sizeof(term));
***************
*** 941,947 ****
  		struct stat st;
  
  #ifdef KRB4
! 		if (!krbflag)
  		    printf("\nWarning: No Kerberos tickets obtained.\n\n");
  #endif /* KRB4 */
  		motd();
--- 951,957 ----
  		struct stat st;
  
  #ifdef KRB4
! 		if (!krbflag&& !fflag && !Fflag && !eflag )
  		    printf("\nWarning: No Kerberos tickets obtained.\n\n");
  #endif /* KRB4 */
  		motd();
*** appl/telnet/telnetd/,sys_term.c	Tue Apr 25 22:00:22 1995
--- appl/telnet/telnetd/sys_term.c	Fri Oct  6 10:49:06 1995
***************
*** 1098,1108 ****
--- 1098,1110 ----
  		fatal(net, "I_PUSH ptem");
  	if (ioctl(t, I_PUSH, "ldterm") < 0)
  		fatal(net, "I_PUSH ldterm");
+ #ifndef __sgi__
  	if (ioctl(t, I_PUSH, "ttcompat") < 0)
  		fatal(net, "I_PUSH ttcompat");
  	if (ioctl(pty, I_PUSH, "pckt") < 0)
  		fatal(net, "I_PUSH pckt");
  #endif
+ #endif
  
  	/*
  	 * set up the tty modes as we like them to be.
***************
*** 1251,1257 ****
  		(void) signal(SIGHUP, SIG_IGN);
  		(void) ioctl(t, TCVHUP, (char *)0);
  		(void) signal(SIGHUP, SIG_DFL);
! 		setpgrp();
  
  #if		defined(_SC_CRAY_SECURE_SYS)
  		if (secflag) {
--- 1253,1259 ----
  		(void) signal(SIGHUP, SIG_IGN);
  		(void) ioctl(t, TCVHUP, (char *)0);
  		(void) signal(SIGHUP, SIG_DFL);
! 		setpgrp(0,0);
  
  #if		defined(_SC_CRAY_SECURE_SYS)
  		if (secflag) {
***************
*** 1390,1396 ****
  		register int pid = i;
  		void sigjob P((int));
  
! 		setpgrp();
  		utmp_sig_reset();		/* reset handler to default */
  		/*
  		 * Create utmp entry for child
--- 1392,1398 ----
  		register int pid = i;
  		void sigjob P((int));
  
! 		setpgrp(0,0);
  		utmp_sig_reset();		/* reset handler to default */
  		/*
  		 * Create utmp entry for child

home help back first fref pref prev next nref lref last post