[krbdev.mit.edu #6520] struct utmp's ut_tv isn't always a struct timeval
The RT System itself via RT
rt-comment at krbdev.mit.edu
Fri Jun 26 17:48:47 EDT 2009
>From krb5-bugs-incoming-bounces at PCH.mit.edu Fri Jun 26 21:48:47 2009
Return-Path: <krb5-bugs-incoming-bounces at PCH.mit.edu>
X-Original-To: krb5-send-pr-nospam1 at krbdev.mit.edu
Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90])
by krbdev.mit.edu (Postfix) with ESMTP id E752ECC8E5;
Fri, 26 Jun 2009 21:48:46 +0000 (UTC)
Received: from pch.mit.edu (pch.mit.edu [127.0.0.1])
by pch.mit.edu (8.13.6/8.12.8) with ESMTP id n5QLmkUu030475;
Fri, 26 Jun 2009 17:48:46 -0400
Received: from pacific-carrier-annex.mit.edu (PACIFIC-CARRIER-ANNEX.MIT.EDU
[18.7.21.83])
by pch.mit.edu (8.13.6/8.12.8) with ESMTP id n5QKsv65019081
for <krb5-bugs-incoming at PCH.mit.edu>; Fri, 26 Jun 2009 16:54:57 -0400
Received: from mit.edu (W92-130-BARRACUDA-3.MIT.EDU [18.7.21.224])
by pacific-carrier-annex.mit.edu (8.13.6/8.9.2) with ESMTP id
n5QKsoNg025721
for <krb5-bugs at mit.edu>; Fri, 26 Jun 2009 16:54:50 -0400 (EDT)
Received: from mx1.redhat.com (localhost [127.0.0.1])
by mit.edu (Spam Firewall) with ESMTP id A472315787A1
for <krb5-bugs at mit.edu>; Fri, 26 Jun 2009 16:54:49 -0400 (EDT)
Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by mit.edu with
ESMTP id 0WZ3EnWXNLHInC64 for <krb5-bugs at mit.edu>;
Fri, 26 Jun 2009 16:54:49 -0400 (EDT)
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com
[172.16.52.254])
by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n5QKslL6013801
for <krb5-bugs at mit.edu>; Fri, 26 Jun 2009 16:54:47 -0400
Received: from blade.bos.redhat.com (blade.bos.redhat.com [10.16.0.23])
by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5QKsiRa021504
for <krb5-bugs at mit.edu>; Fri, 26 Jun 2009 16:54:46 -0400
Received: from blade.bos.redhat.com (localhost.localdomain [127.0.0.1])
by blade.bos.redhat.com (8.14.3/8.14.2) with ESMTP id n5QKsiB7019598
for <krb5-bugs at mit.edu>; Fri, 26 Jun 2009 16:54:44 -0400
Received: (from nalin at localhost)
by blade.bos.redhat.com (8.14.3/8.14.3/Submit) id n5QKsiUD019592;
Fri, 26 Jun 2009 16:54:44 -0400
Date: Fri, 26 Jun 2009 16:54:44 -0400
Message-Id: <200906262054.n5QKsiUD019592 at blade.bos.redhat.com>
To: krb5-bugs at mit.edu
Subject: struct utmp's ut_tv isn't always a struct timeval
From: nalin at redhat.com
X-send-pr-version: 3.99
X-Scanned-By: MIMEDefang 2.42
X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254
X-Spam-Score: 0.00
X-Spam-Flag: NO
X-Mailman-Approved-At: Fri, 26 Jun 2009 17:48:44 -0400
X-BeenThere: krb5-bugs-incoming at mailman.mit.edu
X-Mailman-Version: 2.1.6
Precedence: list
Reply-To: nalin at redhat.com
Sender: krb5-bugs-incoming-bounces at PCH.mit.edu
Errors-To: krb5-bugs-incoming-bounces at PCH.mit.edu
>Submitter-Id: net
>Originator:
>Organization:
>Confidential: no
>Synopsis: struct utmp's ut_tv isn't always a struct timeval
>Severity: non-critical
>Priority: medium
>Category: pty
>Class: sw-bug
>Release: 1.7
>Environment:
System: Linux blade.bos.redhat.com 2.6.29.4-167.fc11.x86_64 #1 SMP Wed May 27 17:27:08 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
Architecture: x86_64
>Description:
On my x86_64 Fedora system using glibc, the ut_tv field of a utmp
structure isn't a struct timeval (which would contain a pair of 64-bit
time_t values), but is an anonymous structure which has a pair of
int32_t values with the same names. Here's the snippet from
<bits/utmp.h>:
/* The ut_session and ut_tv fields must be the same size when compiled
32- and 64-bit. This allows data files and shared memory to be
shared between 32- and 64-bit applications. */
#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
int32_t ut_session; /* Session ID, used for windowing. */
struct
{
int32_t tv_sec; /* Seconds. */
int32_t tv_usec; /* Microseconds. */
} ut_tv; /* Time entry was made. */
#else
long int ut_session; /* Session ID, used for windowing. */
struct timeval ut_tv; /* Time entry was made. */
#endif
Passing the address of this ut_tv to gettimeofday() triggers a
compiler warning.
>How-To-Repeat:
(Compiler warnings.)
>Fix:
This patch quiets the warnings for me. In update_utmp.c, it
uses a temporary. In login.c, the variables involved don't
appear to be used, so the code can just be removed.
Index: src/appl/libpty/update_utmp.c
===================================================================
--- src/appl/libpty/update_utmp.c (revision 22423)
+++ src/appl/libpty/update_utmp.c (working copy)
@@ -291,6 +291,12 @@
* The ut_exit field seems to exist in utmp, but not utmpx. The files
* utmp and wtmp seem to exist, but not utmpx, or wtmpx.
*
+ * glibc:
+ *
+ * The ut_tv field of struct utmp/utmpx may be an anonymous structure
+ * containing 32-bit values on systems where time_t is 64 bits. Its
+ * fields have the same names, though.
+ *
* libpty Implementation Decisions:
* --------------------------------
*
@@ -505,6 +511,8 @@
const char *line, const char *host, int flags)
{
PTY_STRUCT_UTMPX utx, *utxtmp, utx2;
+ struct timeval ut_tv;
+ time_t login_time;
const char *cp;
size_t len;
char utmp_id[5];
@@ -577,10 +585,13 @@
utxtmp = best_utxent(&utx);
#ifdef HAVE_SETUTXENT
- if (gettimeofday(&utx.ut_tv, NULL))
+ if (gettimeofday(&ut_tv, NULL))
return errno;
+ utx.ut_tv.tv_sec = ut_tv.tv_sec;
+ utx.ut_tv.tv_usec = ut_tv.tv_usec;
#else
- (void)time(&utx.ut_time);
+ (void)time(&login_time);
+ utx.ut_time = login_time;
#endif
/*
* On what system is there not ut_host? Unix98 doesn't mandate
Index: src/appl/bsd/login.c
===================================================================
--- src/appl/bsd/login.c (revision 22423)
+++ src/appl/bsd/login.c (working copy)
@@ -719,7 +719,6 @@
char *domain, **envinit, *ttyn, *tty;
char tbuf[MAXPATHLEN + 2];
char *ttyname(), *crypt(), *getpass();
- time_t login_time;
int retval;
int rewrite_ccache = 1; /*try to write out ccache*/
#ifdef KRB5_GET_TICKETS
@@ -1071,9 +1070,6 @@
/* nothing else left to fail -- really log in */
{
- struct utmp utmp;
-
- login_time = time(&utmp.ut_time);
if ((retval = pty_update_utmp(PTY_USER_PROCESS, getpid(), username,
ttyn, hostname,
PTY_TTYSLOT_USABLE)) < 0)
More information about the krb5-bugs
mailing list