]> git.pld-linux.org Git - packages/util-linux.git/blame - util-linux-login-timeval.patch
- pass --enable-login-chown-vcs to configure
[packages/util-linux.git] / util-linux-login-timeval.patch
CommitLineData
5545a732
JR
1
2On 64-bit platforms such as x86_64, glibc is usally built with 32-bit
3compatibilty for various structures. One of them is utmp.
4
5What this means is that gettimeofday(&ut.ut_tv, NULL) on x86_64 will
6end up overwriting the first parts of ut_addr_v6, leading to garbage
7in the utmp file.
8
9
10--- util-linux-2.13-pre6/login-utils/login.c.kzak 2006-08-10 11:38:33.000000000 +0200
11+++ util-linux-2.13-pre6/login-utils/login.c 2006-08-10 11:38:49.000000000 +0200
12@@ -257,6 +257,7 @@
13 static void
14 logbtmp(const char *line, const char *username, const char *hostname) {
15 struct utmp ut;
16+ struct timeval tv;
17
18 memset(&ut, 0, sizeof(ut));
19
20@@ -267,7 +268,9 @@
21 xstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
22
23 #if defined(_HAVE_UT_TV) /* in <utmpbits.h> included by <utmp.h> */
24- gettimeofday(&ut.ut_tv, NULL);
25+ gettimeofday(&tv, NULL);
26+ ut.ut_tv.tv_sec = tv.tv_sec;
27+ ut.ut_tv.tv_usec = tv.tv_usec;
28 #else
29 {
30 time_t t;
31@@ -872,6 +875,7 @@
32 {
33 struct utmp ut;
34 struct utmp *utp;
35+ struct timeval tv;
36
37 utmpname(_PATH_UTMP);
38 setutent();
39@@ -911,7 +915,9 @@
40 strncpy(ut.ut_user, username, sizeof(ut.ut_user));
41 xstrncpy(ut.ut_line, tty_name, sizeof(ut.ut_line));
42 #ifdef _HAVE_UT_TV /* in <utmpbits.h> included by <utmp.h> */
43- gettimeofday(&ut.ut_tv, NULL);
44+ gettimeofday(&tv, NULL);
45+ ut.ut_tv.tv_sec = tv.tv_sec;
46+ ut.ut_tv.tv_usec = tv.tv_usec;
47 #else
48 {
49 time_t t;
This page took 0.0787 seconds and 4 git commands to generate.