summaryrefslogtreecommitdiff
blob: 26d1161b7936f193e36a730df1478fd5e46b0ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
On 64bit arches which have 32bit multilib support, the utmp struct is
the same ... thus we cannot assume that utmp.ut_tv is of type time_t

--- sysvinit/src/utmp.c
+++ sysvinit/src/utmp.c
@@ -47,6 +47,7 @@ void write_wtmp
 	int fd;
 	struct utmp utmp;
 	struct utsname uname_buf;
+	struct timeval tv;
 
 	/*
 	 *	Try to open the wtmp file. Note that we even try
@@ -76,7 +77,9 @@ void write_wtmp
 	 */
 	memset(&utmp, 0, sizeof(utmp));
 #if defined(__GLIBC__)
-	gettimeofday(&utmp.ut_tv, NULL);
+	gettimeofday(&tv, NULL);
+	utmp.ut_tv.tv_sec = tv.tv_sec;
+	utmp.ut_tv.tv_usec = tv.tv_usec;
 #else
 	time(&utmp.ut_time);
 #endif
@@ -113,6 +116,7 @@ static void write_utmp
 	struct utmp utmp;
 	struct utmp tmp;
 	struct utmp *utmptr;
+	struct timeval tv;
 
 	/*
 	 *	Can't do much if UTMP_FILE is not present.
@@ -144,7 +148,9 @@ static void write_utmp
 	utmp.ut_pid = pid;
 	strncpy(utmp.ut_id, id, sizeof(utmp.ut_id));
 #if defined(__GLIBC__)
-	gettimeofday(&utmp.ut_tv, NULL);
+	gettimeofday(&tv, NULL);
+	utmp.ut_tv.tv_sec = tv.tv_sec;
+	utmp.ut_tv.tv_usec = tv.tv_usec;
 #else
 	time(&utmp.ut_time);
 #endif