[2.1.1p4] utmp patch for SunOS 4.1.x

Nate Itkin nitkin at europa.com
Tue Aug 1 19:10:30 EST 2000


Follow-on to Charles Levert's <charles at comm.polymtl.ca> work on
utmp_write_direct.

Fixed:

  -- At logout, the utmp entry is cleared.   Tested on SunOS 4.1.4. 
     The code I added to loginrec.c is restricted to SUNOS4 pending 
     QA testing on other platforms.

     This patch incorporates the work done by Charles Levert on 
     7/25/2000 00:43:22.   (Do any of us sleep at night?)

Remaining:

  -- Test on NeXT and other operating systems that need utmp_write_direct
     (those without entutent, getutent, getutid, getutline, ...)  If 
     successful, the SUNOS4 restriction could be removed and the FIXME
     can be eliminated.  If not, similar code will need to be added 
     to support those operating systems.

  -- In the unlikely case that other operating systems have prereqs. 
     for ttyent.h, those .h files will need to be added to configure.in,
     includes.h, and config.h.in.
     
Install:  (prereq:  GNU autoconf and Larry Wall's patch)

  o  save attached context diffs to "patchfile"

     -- patch < patchfile            (apply patch to 2.1.1p4 release)
     -- autoconf                     (generate configure, config.h, etc.)

  o  follow ssh install docs.  In a nutshell,

     -- configure                    
     -- gmake
     -- gmake install

-- 
- Nate Itkin
- Nate.Itkin at europa.com
- "Looking for an off-ramp on the Information Superhighway"

--------------------- cut-here --------------------- 

*** config.h.in.orig	Mon Jul 31 10:06:48 2000
--- config.h.in	Mon Jul 31 10:10:36 2000
***************
*** 297,302 ****
--- 297,305 ----
  /* Define if you have the getutxline function.  */
  #undef HAVE_GETUTXLINE
  
+ /* Define if you have the getttyent function.  */
+ #undef HAVE_GETTTYENT
+ 
  /* Define if you have the inet_aton function.  */
  #undef HAVE_INET_ATON
  
***************
*** 482,487 ****
--- 485,493 ----
  
  /* Define if you have the <time.h> header file.  */
  #undef HAVE_TIME_H
+ 
+ /* Define if you have the <ttyent.h> header file.  */
+ #undef HAVE_TTYENT_H
  
  /* Define if you have the <usersec.h> header file.  */
  #undef HAVE_USERSEC_H
*** configure.in.orig	Fri Jul 14 21:59:14 2000
--- configure.in	Mon Jul 31 23:44:12 2000
***************
*** 137,142 ****
--- 137,147 ----
  *-*-sunos4*)
  	CFLAGS="$CFLAGS -DSUNOS4"
  	AC_CHECK_FUNCS(getpwanam)
+         conf_utmp_location=/etc/utmp
+         conf_wtmp_location=/var/adm/wtmp
+         conf_lastlog_location=/var/adm/lastlog
+         MANTYPE='$(CATMAN)'
+         mansubdir=cat
  	;;
  *-sni-sysv*)
  	CFLAGS="$CFLAGS -I/usr/local/include"
***************
*** 216,225 ****
  fi
  
  # Checks for header files.
! AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h usersec.h util.h utmp.h utmpx.h)
  
  # Checks for library functions.
! AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage inet_aton innetgr md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop)
  dnl    checks for time functions
  AC_CHECK_FUNCS(gettimeofday time)
  dnl    checks for libutil functions
--- 221,230 ----
  fi
  
  # Checks for header files.
! AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h)
  
  # Checks for library functions.
! AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage getttyent inet_aton innetgr md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop)
  dnl    checks for time functions
  AC_CHECK_FUNCS(gettimeofday time)
  dnl    checks for libutil functions
*** defines.h.orig	Thu Jun 22 15:23:34 2000
--- defines.h	Tue Aug  1 00:33:17 2000
***************
*** 329,346 ****
  #endif
  
  /* FIXME: put default paths back in */
! #if !defined(UTMP_FILE) && defined(_PATH_UTMP)
! #  define UTMP_FILE _PATH_UTMP
  #endif
! #if !defined(WTMP_FILE) && defined(_PATH_WTMP)
! #  define WTMP_FILE _PATH_WTMP
  #endif
  /* pick up the user's location for lastlog if given */
! #if !defined(LASTLOG_FILE) && defined(_PATH_LASTLOG)
! #  define LASTLOG_FILE _PATH_LASTLOG
! #endif
! #if !defined(LASTLOG_FILE) && defined(CONF_LASTLOG_FILE)
! #  define LASTLOG_FILE CONF_LASTLOG_FILE
  #endif
  
  
--- 329,361 ----
  #endif
  
  /* FIXME: put default paths back in */
! #ifndef UTMP_FILE
! #  ifdef _PATH_UTMP
! #    define UTMP_FILE _PATH_UTMP
! #  else
! #    ifdef CONF_UTMP_FILE
! #      define UTMP_FILE CONF_UTMP_FILE
! #    endif
! #  endif
  #endif
! #ifndef WTMP_FILE
! #  ifdef _PATH_WTMP
! #    define WTMP_FILE _PATH_WTMP
! #  else
! #    ifdef CONF_WTMP_FILE
! #      define WTMP_FILE CONF_WTMP_FILE
! #    endif
! #  endif
  #endif
  /* pick up the user's location for lastlog if given */
! #ifndef LASTLOG_FILE
! #  ifdef _PATH_LASTLOG
! #    define LASTLOG_FILE _PATH_LASTLOG
! #  else
! #    ifdef CONF_LASTLOG_FILE
! #      define LASTLOG_FILE CONF_LASTLOG_FILE
! #    endif
! #  endif
  #endif
  
  
*** includes.h.orig	Mon Jul 31 10:29:28 2000
--- includes.h	Mon Jul 31 10:30:39 2000
***************
*** 70,75 ****
--- 70,78 ----
  #ifdef HAVE_SYS_BSDTTY_H
  # include <sys/bsdtty.h>
  #endif
+ #ifdef HAVE_TTYENT_H
+ # include <ttyent.h>
+ #endif
  #ifdef USE_PAM
  # include <security/pam_appl.h>
  #endif
*** loginrec.c.orig	Mon Jul 10 19:15:54 2000
--- loginrec.c	Mon Jul 31 10:37:45 2000
***************
*** 723,730 ****
--- 723,751 ----
  	int tty;
  
  	/* FIXME: (ATL) ttyslot() needs local implementation */
+ 
+ #if defined(SUNOS4) && defined(HAVE_GETTTYENT)
+ 
+         register struct ttyent *ty;
+         tty=0;
+         setttyent();
+         while ((struct ttyent *)0 != (ty = getttyent())) {
+            tty++;
+            if(0 == strncmp(ty->ty_name,ut->ut_line,sizeof(ut->ut_line)))
+               break;
+         }
+         endttyent();
+         if((struct ttyent *)0 == ty) {
+            log("utmp_write_entry: tty not found");
+            return(1);
+         }
+ 
+ #else /* FIXME */
+ 
  	tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */
  
+ #endif /* SUNOS4 && HAVE_GETTTYENT */
+ 
  	if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) {
  		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
  		/*
***************
*** 740,746 ****
  		}
  		
  		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
! 		if (atomicio(write, fd, ut, sizeof(ut)) != sizeof(ut))
  			log("utmp_write_direct: error writing %s: %s",
  			    UTMP_FILE, strerror(errno));
        
--- 761,767 ----
  		}
  		
  		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
! 		if (atomicio(write, fd, ut, sizeof(struct utmp)) != sizeof(struct utmp))
  			log("utmp_write_direct: error writing %s: %s",
  			    UTMP_FILE, strerror(errno));
        






More information about the openssh-unix-dev mailing list