Comment 3 for bug 560925

Atanas (atanasd) wrote :

It didn't follow into the while (login_p) because read_wtmp() returned garbage.
It was attempting to read an always 32-bit value (ut.ut_time, actually ut.ut_tv.tv_sec) with an arch dependent (time_t *) pointer, which on 64-bit systems expects 64-bits of data. So half of the bits were some random junk and read_wtmp() was just skipping all past login session records.

The following patch appears to fix that:

--- timeoutd.c-old 2012-05-10 16:00:21.000000000 +0200
+++ timeoutd.c 2012-05-11 14:38:35.514021308 +0200
@@ -418,7 +418,8 @@
.
     while (fread(&ut, sizeof(struct utmp), 1, fp) == 1)
     {
- tm = localtime(&ut.ut_time);
+ time_t utmp_time = ut.ut_time;
+ tm = localtime(&utmp_time);
.
       if (tm->tm_year != now.tm_year || tm->tm_yday != now.tm_yday)
         break;