[1298] in Kerberos-V5-bugs

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

appl/bsd should use system logwtmp

daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Sun Mar 26 15:59:53 1995

From: epeisach@MIT.EDU
Date: Sun, 26 Mar 1995 15:59:42 -0500
To: krb5-bugs@MIT.EDU


a) The bsd sourecs of logwtmp is 'nonstandard' in that it does not seem
to match any reference sources I can find for same...

It does not need to be different. Someone added an extra argument
indicating that someone was logging in. This was extraneous as it could
be determined by the other arguments... 

b) Changes to logutil.c to test and figure out what the last argument
being passed was.

c) krshd.c was changed to get rid of the extra argument

d) configure.in changed to detect for logwtmp present on the system. (in
particular libutil) This is true for OSF/1 and netbsd... The usage of
logwtmp will then conform to the calling convention which is present in
the change.

Index: configure.in
===================================================================
RCS file: /mit/krb5/.cvsroot/src/appl/bsd/configure.in,v
retrieving revision 5.47
diff -c -r5.47 configure.in
*** configure.in	1995/03/24 04:29:53	5.47
--- configure.in	1995/03/26 20:45:23
***************
*** 7,12 ****
--- 7,13 ----
  dnl dbm libs for use of an_to_ln
  AC_CHECK_LIB(ndbm,main)
  AC_CHECK_LIB(dbm,main)
+ AC_CHECK_LIB(util,logwtmp)
  dnl
  dnl AIX has them all; SCO might too
  LOGINLIBS=
***************
*** 32,39 ****
  AC_FUNC_CHECK(waitpid,AC_DEFINE(HAVE_WAITPID))
  AC_FUNC_CHECK(setsid,AC_DEFINE(HAVE_SETSID))
  AC_FUNC_CHECK(line_push,AC_DEFINE(HAVE_LINE_PUSH))
! AC_FUNC_CHECK(ptsname,AC_DEFINE(HAVE_PTSNAME))
! AC_FUNC_CHECK(grantpt,AC_DEFINE(HAVE_GRANTPT))
  AC_HAVE_HEADERS(sys/filio.h sys/sockio.h unistd.h stdlib.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h)
  AC_REPLACE_FUNCS(getdtablesize)
  CHECK_SIGNALS
--- 33,39 ----
  AC_FUNC_CHECK(waitpid,AC_DEFINE(HAVE_WAITPID))
  AC_FUNC_CHECK(setsid,AC_DEFINE(HAVE_SETSID))
  AC_FUNC_CHECK(line_push,AC_DEFINE(HAVE_LINE_PUSH))
! AC_CHECK_FUNCS(ptsname grantpt openpty setlogin logwtmp)
  AC_HAVE_HEADERS(sys/filio.h sys/sockio.h unistd.h stdlib.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h)
  AC_REPLACE_FUNCS(getdtablesize)
  CHECK_SIGNALS
Index: krshd.c
===================================================================
RCS file: /mit/krb5/.cvsroot/src/appl/bsd/krshd.c,v
retrieving revision 5.24
diff -c -r5.24 krshd.c
*** krshd.c	1995/02/28 09:43:29	5.24
--- krshd.c	1995/03/26 20:36:43
***************
*** 786,798 ****
      if (port) {
  	/* Place entry into wtmp */
  	sprintf(ttyn,"krsh%1d",getpid());
! 	logwtmp(ttyn,locuser,hostname,1);
      }
      /*      We are simply execing a program over rshd : log entry into wtmp,
  	    as kexe(pid), then finish out the session right after that.
  	    Syslog should have the information as to what was exec'd */
      else {
! 	logwtmp(ttyn,locuser,hostname,1);
      }
      
  #ifdef CRAY
--- 786,798 ----
      if (port) {
  	/* Place entry into wtmp */
  	sprintf(ttyn,"krsh%1d",getpid());
! 	logwtmp(ttyn,locuser,hostname);
      }
      /*      We are simply execing a program over rshd : log entry into wtmp,
  	    as kexe(pid), then finish out the session right after that.
  	    Syslog should have the information as to what was exec'd */
      else {
! 	logwtmp(ttyn,locuser,hostname);
      }
      
  #ifdef CRAY
***************
*** 1147,1153 ****
  		   "Shell process completed.");
  #endif
  	    /* Finish session in wmtp */
! 	    logwtmp(ttyn,"","",0);
  	    exit(0);
  	}
  #ifdef SETPGRP_TWOARG
--- 1147,1153 ----
  		   "Shell process completed.");
  #endif
  	    /* Finish session in wmtp */
! 	    logwtmp(ttyn,"","");
  	    exit(0);
  	}
  #ifdef SETPGRP_TWOARG
***************
*** 1174,1180 ****
  	    as kexe(pid), then finish out the session right after that.
  	    Syslog should have the information as to what was exec'd */
      else {
! 	logwtmp(ttyn,"","",0);
      }
      
      if (*pwd->pw_shell == '\0')
--- 1174,1180 ----
  	    as kexe(pid), then finish out the session right after that.
  	    Syslog should have the information as to what was exec'd */
      else {
! 	logwtmp(ttyn,"","");
      }
      
      if (*pwd->pw_shell == '\0')
***************
*** 1209,1215 ****
      exit(1);
      
    signout_please:
!     logwtmp(ttyn,"","",0);
      exit(1);
  }
      
--- 1209,1215 ----
      exit(1);
      
    signout_please:
!     logwtmp(ttyn,"","");
      exit(1);
  }
      
***************
*** 1278,1284 ****
  #endif
      wait(0);
      
!     logwtmp(ttyn,"","",0);
      syslog(LOG_INFO ,"Shell process completed.");
      exit(0);
  }
--- 1278,1284 ----
  #endif
      wait(0);
      
!     logwtmp(ttyn,"","");
      syslog(LOG_INFO ,"Shell process completed.");
      exit(0);
  }
Index: logutil.c
===================================================================
RCS file: /mit/krb5/.cvsroot/src/appl/bsd/logutil.c,v
retrieving revision 5.18
diff -c -r5.18 logutil.c
*** logutil.c	1995/03/25 04:16:28	5.18
--- logutil.c	1995/03/26 20:41:49
***************
*** 186,205 ****
  	}
  	(void)close(fd);
      }
  #endif /* HAVE_SETUTENT */
  #endif /* HAVE_UPDWTMP */
  }
  
! void logwtmp(tty, locuser, host, loggingin)
      char *tty;
      char *locuser;
      char *host;
-     int loggingin;
  {
      struct utmp ut;
      char *tmpx;
      char utmp_id[5];
  
  #ifndef NO_UT_HOST
      strncpy(ut.ut_host, host, sizeof(ut.ut_host));
  #endif
--- 178,199 ----
  	}
  	(void)close(fd);
      }
  #endif /* HAVE_UPDWTMP */
  }
  
! #ifndef HAVE_LOGWTMP
! void logwtmp(tty, locuser, host)
      char *tty;
      char *locuser;
      char *host;
  {
      struct utmp ut;
      char *tmpx;
      char utmp_id[5];
  
+     /* Will be empty for logout */
+     int loggingin = locuser[0];
+ 
  #ifndef NO_UT_HOST
      strncpy(ut.ut_host, host, sizeof(ut.ut_host));
  #endif
***************
*** 222,224 ****
--- 216,219 ----
  
      update_wtmp(&ut);
  }
+ #endif

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