9b20bca
Handle ut_tv not always being a struct timeval.  RT#6520
c73bf3f
0c04f80
Index: krb5/src/appl/libpty/update_utmp.c
0c04f80
===================================================================
0c04f80
--- krb5/src/appl/libpty/update_utmp.c	(revision 22423)
0c04f80
+++ krb5/src/appl/libpty/update_utmp.c	(working copy)
0c04f80
@@ -291,6 +291,12 @@
0c04f80
  * The ut_exit field seems to exist in utmp, but not utmpx. The files
0c04f80
  * utmp and wtmp seem to exist, but not utmpx, or wtmpx.
0c04f80
  *
0c04f80
+ * glibc:
0c04f80
+ *
0c04f80
+ * The ut_tv field of struct utmp/utmpx may be an anonymous structure
0c04f80
+ * containing 32-bit values on systems where time_t is 64 bits.  Its
0c04f80
+ * fields have the same names, though.
0c04f80
+ *
0c04f80
  * libpty Implementation Decisions:
0c04f80
  * --------------------------------
0c04f80
  *
0c04f80
@@ -505,6 +511,8 @@
0c04f80
 		    const char *line, const char *host, int flags)
0c04f80
 {
0c04f80
     PTY_STRUCT_UTMPX utx, *utxtmp, utx2;
0c04f80
+    struct timeval ut_tv;
0c04f80
+    time_t login_time;
0c04f80
     const char *cp;
0c04f80
     size_t len;
0c04f80
     char utmp_id[5];
0c04f80
@@ -577,10 +585,13 @@
0c04f80
 	utxtmp = best_utxent(&utx;;
0c04f80
 
0c04f80
 #ifdef HAVE_SETUTXENT
0c04f80
-    if (gettimeofday(&utx.ut_tv, NULL))
0c04f80
+    if (gettimeofday(&ut_tv, NULL))
0c04f80
 	return errno;
0c04f80
+    utx.ut_tv.tv_sec = ut_tv.tv_sec;
0c04f80
+    utx.ut_tv.tv_usec = ut_tv.tv_usec;
0c04f80
 #else
0c04f80
-    (void)time(&utx.ut_time);
0c04f80
+    (void)time(&login_time);
0c04f80
+    utx.ut_time = login_time;
0c04f80
 #endif
0c04f80
     /*
0c04f80
      * On what system is there not ut_host?  Unix98 doesn't mandate
0c04f80
Index: krb5/src/appl/bsd/login.c
0c04f80
===================================================================
0c04f80
--- krb5/src/appl/bsd/login.c	(revision 22423)
0c04f80
+++ krb5/src/appl/bsd/login.c	(working copy)
0c04f80
@@ -719,7 +719,6 @@
c73bf3f
     char *domain, **envinit, *ttyn, *tty;
c73bf3f
     char tbuf[MAXPATHLEN + 2];
c73bf3f
     char *ttyname(), *crypt(), *getpass();
c73bf3f
-    time_t login_time;
c73bf3f
     int retval;
c73bf3f
     int rewrite_ccache = 1; /*try to write out ccache*/
c73bf3f
 #ifdef KRB5_GET_TICKETS
0c04f80
@@ -1071,9 +1070,6 @@
c73bf3f
 
c73bf3f
     /* nothing else left to fail -- really log in */
c73bf3f
     {
c73bf3f
-	struct utmp utmp;
c73bf3f
-
c73bf3f
-	login_time = time(&utmp.ut_time);
c73bf3f
 	if ((retval = pty_update_utmp(PTY_USER_PROCESS, getpid(), username,
c73bf3f
 				      ttyn, hostname,
c73bf3f
 				      PTY_TTYSLOT_USABLE)) < 0)