[1008] in Kerberos-V5-bugs

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

rlogind under solaris

daemon@ATHENA.MIT.EDU (Jeff Bacon)
Fri Dec 23 15:45:01 1994

To: krb5-bugs@MIT.EDU
Date: Fri, 23 Dec 1994 15:44:45 -0500 (EST)
From: Jeff Bacon <bacon@mtu.edu>

I dunno about anyone else, but I have had really poor luck at getting
the rlogind supplied with krb5 to work under solaris at all. it kinda
works, but it does via the BSD-compat ptys, which don't support job control
or many other things. also, none of the utmp/wtmp stuff works right,
for various reasons. and it doesn't work with the solaris /bin/login.

Doug Engert and Charles Athey have done some rewrites of the code
for the Sandia version and for what's used at ANL, but these seem never
to have made it into the distribution. 

a quick cheap hack would be to push the ldterm/ttcompat modules onto
the BSD ptys stream, but even that is a bit of a kludge.

the diffs that follow implement a more correct method of handling
the ptys under Solaris, using the standard pts/ptmx model for pty-handling.
credits to Doug Engert for some of the ideas used, though the code is mine.
compiles OK with both SunCC 3.0 and gcc 2.6.2.

they also provide a first cut at implementing "correct" utmp/wtmp
handling using the *utx* routines, at least while using the native
/bin/login. 

consider this a work-in-progress - I intend to rewrite the logutil stuff
to use the *utx* stuff as well, so that krshd and login.krb5 will 
write correct entries.

-bacon
--
= Jeff Bacon              General Systems Hack, Michigan Technological Univ. =
= bacon@mtu.edu    ph-(906)487-2197 fax-(906)487-2782 DoD#2110   I'm the NRA = 
=  if you think it's bad here, imagine what Hell is like. sure you wanna go? =


*** krlogind.c	Fri Dec 23 15:33:22 1994
--- krlogind.c.REAL	Mon Dec 12 17:54:40 1994
***************
*** 99,107 ****
   */
  #define LOG_REMOTE_REALM
  #define CRYPT
- #define SERVE_V4
- #undef LOGIN_PROGRAM
- #define DO_NOT_USE_K_LOGIN
  
  #include <stdio.h>
  #include <sys/types.h>
--- 99,104 ----
***************
*** 190,207 ****
  #define killpg(pid, sig) kill(-(pid), (sig))
  #endif
  
- /* evil kludge hack */
- #if defined(sun) && (defined(__SVR4) || defined(__svr4__))
- #define SOLARIS 
- #include <sys/stream.h>		/* for new getpty */
- #include <sys/stropts.h>
- #ifdef DO_NOT_USE_K_LOGIN
- char utmp_id[5];
- #include <utmpx.h>
- #endif
- #endif
- 
- 
  #ifdef NO_WINSIZE
  struct winsize {
      unsigned short ws_row, ws_col;
--- 187,192 ----
***************
*** 649,665 ****
  	    struct sgttyb b;
  #endif /* USE_TERMIO */
  #endif /* POSIX_TERMIOS */
- 
- #ifdef SOLARIS
-             /* push the term modules on the stream */
-             if (ioctl(t, I_PUSH, "ptem") < 0)
-               fatalperror(f, "IPUSH-pterm");
-             if (ioctl(t, I_PUSH, "ldterm") < 0)
-               fatalperror(f, "IPUSH-ldterm");
-             if (ioctl(t, I_PUSH, "ttcompat") < 0)
-               fatalperror(f, "IPUSH-ttcompat");
- #endif /* SOLARIS */
- 
  #ifdef SYSV
  	    (void) setpgrp();
  	    /* SYSV open slave device: We closed it above so pgrp
--- 634,639 ----
***************
*** 791,829 ****
  #endif
  	
  #ifdef DO_NOT_USE_K_LOGIN
- #ifdef SOLARIS
- 	/*
- 	  the default solaris /bin/login wants rlogin to write a
- 	   utmpx entry for it. why? who knows. so, we write one. 
- 	   5/5/94 -jkb
- 	*/
- 	{
- 		struct utmpx ent;
- 		int tmpx;
- 
- 		strcpy(ent.ut_user,"rlogin");
- 		strcpy(ent.ut_line,(line+sizeof("/dev/")-1));
- 		/*
- 		   this needs to be unique to a session, so I'll
- 		   tie it to the pts number; we store it in global utmp_id
- 		   so logout can fetch it later...
- 		*/
- 		sscanf(line,"/dev/pts/%d",&tmpx);
- 		sprintf(utmp_id,"kl%02d",tmpx);
- 		strncpy(ent.ut_id,utmp_id,sizeof(ent.ut_id));
- 
- 		ent.ut_pid=getpid();
- 		ent.ut_type=LOGIN_PROCESS;
- 		ent.ut_xtime=time(NULL);
- 
- 		setutxent();
- 		pututxline(&ent);
- 		endutxent();
- 		updwtmpx(WTMPX_FILE,&ent);
- 		
- 		execl(LOGIN_PROGRAM, "login", "-d", line,  "-r", rhost_name, 0);
- 	}
- #endif
  	execl(LOGIN_PROGRAM, "login", "-r", rhost_name, 0);
  #else
  	if (passwd_req)
--- 765,770 ----
***************
*** 1012,1019 ****
  		
  	      top:
  		for (cp = fibuf; cp < fibuf+fcc-1; cp++)
! 		  if ((unsigned char) cp[0] == (unsigned char) magic[0] &&
! 		      (unsigned char) cp[1] == (unsigned char) magic[1]) {
  		      left = fcc - (cp-fibuf);
  		      n = control(p, cp, left);
  		      if (n) {
--- 953,960 ----
  		
  	      top:
  		for (cp = fibuf; cp < fibuf+fcc-1; cp++)
! 		  if (cp[0] == magic[0] &&
! 		      cp[1] == magic[1]) {
  		      left = fcc - (cp-fibuf);
  		      n = control(p, cp, left);
  		      if (n) {
***************
*** 1046,1052 ****
  	      break;
  	    else if (pibuf[0] == 0)
  	      pbp++, pcc--;
- #ifndef SOLARIS
  	    else {
  		if (pkcontrol(pibuf[0])) {
  		    pibuf[0] |= oobdata[0];
--- 987,992 ----
***************
*** 1054,1060 ****
  		}
  		pcc = 0;
  	    }
- #endif
  	}
  	if ((obits & (1<<f)) && pcc > 0) {
  	    cc = (*des_write)(f, pbp, pcc);
--- 994,999 ----
***************
*** 1076,1108 ****
  int cleanup()
  {
      char *p;
- 
- #if defined(DO_NOT_USE_K_LOGIN) && defined(SOLARIS)
-         /*
- 	    if we write the wtmp entry here in rlogind, we'll need utmp_id
- 	    to undo it as well, so we might as well do that here too. 
- 	    actually, I wouldn't think this to be strictly correct behavior,
- 	    because we shouldn't actually cut a wtmp entry until we
- 	    actually log in, and login could still not accept the user.
- 	    but since solaris /bin/login insists... *shrug* we can at
- 	    least try to remove it. 12/22/94 -jkb
-         */
-         {
-                 struct utmpx ent;
-  
-                 strcpy(ent.ut_line,(line+sizeof("/dev/")-1));
-                 strncpy(ent.ut_id,utmp_id,sizeof(ent.ut_id));
-                 ent.ut_type=DEAD_PROCESS;
-                 ent.ut_xtime=time(NULL);
-  
-                 setutxent();
- 		getutxid(&ent);
-                 pututxline(&ent);
-                 endutxent();
-                 updwtmpx(WTMPX_FILE,&ent);
-  
-         }
- #else
      
      /* 
        I dont know why P starts with the character '/', but apparently it
--- 1015,1020 ----
***************
*** 1120,1130 ****
      else 
        syslog(LOG_ERR ,
  	     "Cannot delete entry from utmp for %s\n",p);
! 
! #endif /* DO_NOT_USE_KLOGIN && SOLARIS */
! 
! #ifndef SOLARIS	/* under solaris, we don't need to do this */
! 
      (void)chmod(line, 0666);
      (void)chown(line, 0, 0);
  #ifndef STREAMS
--- 1032,1038 ----
      else 
        syslog(LOG_ERR ,
  	     "Cannot delete entry from utmp for %s\n",p);
!     
      (void)chmod(line, 0666);
      (void)chown(line, 0, 0);
  #ifndef STREAMS
***************
*** 1136,1144 ****
      close(Pfd);
      vhangup();
  #endif
- 
- #endif /* SOLARIS */
- 
      shutdown(netf, 2);
      exit(1);
  }
--- 1044,1049 ----
***************
*** 1438,1443 ****
--- 1343,1349 ----
  #endif /* KERBEROS */
  
  
+ 
  getpty(fd,slave)
       int *fd;
       char *slave;
***************
*** 1445,1472 ****
      char c;
      int i,ptynum;
      struct stat stb;
- #ifdef SOLARIS
-     *fd = open("/dev/ptmx",O_RDWR); 
-     if (*fd >= 0) {
-        if (fstat(*fd, &stb) < 0) {
-           close(*fd);
-           return 1;
-        }
-        else {
-           grantpt(*fd);
-           unlockpt(*fd);
-           strcpy(slave,(char *)ptsname(*fd));
-           return(0);
-        }
-     }
-     else return(1);
- #else
  #ifdef STREAMS
  #ifdef sysvimp
      *fd = open("/dev/pty", O_RDWR|O_NDELAY);
  #else
      *fd = open("/dev/ptc", O_RDWR|O_NDELAY);
! #endif /* sysvimp */
      if (*fd >= 0) {
  	if (fstat(*fd, &stb) < 0) {
  	    close(*fd);
--- 1351,1362 ----
      char c;
      int i,ptynum;
      struct stat stb;
  #ifdef STREAMS
  #ifdef sysvimp
      *fd = open("/dev/pty", O_RDWR|O_NDELAY);
  #else
      *fd = open("/dev/ptc", O_RDWR|O_NDELAY);
! #endif
      if (*fd >= 0) {
  	if (fstat(*fd, &stb) < 0) {
  	    close(*fd);
***************
*** 1478,1485 ****
  #else
  	sprintf(slave, "/dev/ttyq%x", ptynum);
  #endif
-     } else { 
-       return(1);
      }
      return (0);
      
--- 1368,1373 ----
***************
*** 1502,1508 ****
      slave[strlen("/dev/")] = 't';
      return(0);
  #endif /* STREAMS */
- #endif /* SOLARIS */
  }
  
  
--- 1390,1395 ----

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