[PATCH] make login compatible with X86-64
problem:
For X86-64, utmp and utmpx contain 32 bit fields to make it compatible with
what a 32-bit application expects.
This leads to the problem, that in lastlog, utmp and utmpx there are fields
for time and timeval that have a different data size than the original time_t
and struct timeval types.
Together with a similar problem in pam (patch will follow shortly) this
prevented me from loggin into a text console.
solution:
This patch changes the relevant areas in login.c and lastlog.c simply by
copying between the 32 and 64 bit data (ignoring the most significant 32 bits
in the 64 bit data type which would not be used in the 32bit-compatible utmp,
utmpx or lastlog files anyway => only correct until 2038).
The patch is against 4.0.3-21.
Karl,
can you please include this patch in your next packages?
amd64-list:
passwd_4.0.3-21.0.1_amd64.deb
login_4.0.3-21.0.1_amd64.deb
are available under:
http://home.arcor.de/hfvogt/debian/
Regards,
Hans-Frieder
--
--
Hans-Frieder Vogt e-mail: hfvogt@arcor.de
--- shadow-4.0.3.orig/src/login.c 2004-03-14 09:02:09.258189000 +0100
+++ shadow-4.0.3/src/login.c 2004-03-14 09:23:02.671641336 +0100
@@ -848,12 +848,30 @@
#endif
if (getdef_str("FTMP_FILE") != NULL) {
#if HAVE_UTMPX_H
+#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+ struct timeval tv;
failent = utxent;
+
+ gettimeofday(&tv, NULL);
+ failent.ut_tv.tv_sec = tv.tv_sec;
+ failent.ut_tv.tv_usec = tv.tv_usec;
+#else
+ failent = utxent;
+
gettimeofday(&(failent.ut_tv), NULL);
+#endif
+#else
+#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+ time_t tim;
+
+ failent = utent;
+ time(&tim);
+ failent.ut_time = tim;
#else
failent = utent;
time(&failent.ut_time);
#endif
+#endif
strncpy(failent.ut_user, failent_user, sizeof(failent.ut_user));
#ifdef USER_PROCESS
failent.ut_type = USER_PROCESS;
--- shadow-4.0.3.orig/src/lastlog.c 2002-01-05 16:41:43.000000000 +0100
+++ shadow-4.0.3/src/lastlog.c 2004-03-14 09:22:26.532135376 +0100
@@ -167,6 +167,9 @@
static int once;
char *cp;
struct tm *tm;
+#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+ time_t ltime;
+#endif
#ifdef HAVE_STRFTIME
char ptime[80];
@@ -184,7 +187,12 @@
#endif
once++;
}
+#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+ ltime = lastlog.ll_time;
+ tm = localtime (<ime);
+#else
tm = localtime (&lastlog.ll_time);
+#endif
#ifdef HAVE_STRFTIME
strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm);
cp = ptime;
Reply to: