diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-11-28 20:24:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-11-28 20:24:52 +0000 |
commit | c3816aaf598ef56e5623cc350bc7b86564e1744a (patch) | |
tree | d6ca82b16fa523651dd4793546b2307700f36653 /libexec | |
parent | 804c80c6ad3756e0c37c1500843df619a3143c40 (diff) |
use gettimeofday() instead of time() in functions called from signal handlers; henning ok
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ftpd/logutmp.c | 6 | ||||
-rw-r--r-- | libexec/ftpd/logwtmp.c | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/libexec/ftpd/logutmp.c b/libexec/ftpd/logutmp.c index 03629ac4d02..4679f3ba1a0 100644 --- a/libexec/ftpd/logutmp.c +++ b/libexec/ftpd/logutmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logutmp.c,v 1.8 2003/12/10 22:57:12 deraadt Exp $ */ +/* $OpenBSD: logutmp.c,v 1.9 2004/11/28 20:24:51 deraadt Exp $ */ /* * Portions Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -98,6 +98,7 @@ ftpd_login(struct utmp *ut) int ftpd_logout(char *line) { + struct timeval tv; struct utmp ut; int rval; @@ -113,7 +114,8 @@ ftpd_logout(char *line) continue; bzero(ut.ut_name, UT_NAMESIZE); bzero(ut.ut_host, UT_HOSTSIZE); - (void)time(&ut.ut_time); + gettimeofday(&tv, NULL); + ut.ut_time = tv.tv_sec; (void)lseek(fd, -(off_t)sizeof(struct utmp), SEEK_CUR); (void)write(fd, &ut, sizeof(struct utmp)); rval = 1; diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c index 90e83932bbc..4ee95a4606a 100644 --- a/libexec/ftpd/logwtmp.c +++ b/libexec/ftpd/logwtmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logwtmp.c,v 1.8 2003/12/10 22:57:12 deraadt Exp $ */ +/* $OpenBSD: logwtmp.c,v 1.9 2004/11/28 20:24:51 deraadt Exp $ */ /* $NetBSD: logwtmp.c,v 1.4 1995/04/11 02:44:58 cgd Exp $ */ /* @@ -36,7 +36,7 @@ static const char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; #else static const char rcsid[] = - "$OpenBSD: logwtmp.c,v 1.8 2003/12/10 22:57:12 deraadt Exp $"; + "$OpenBSD: logwtmp.c,v 1.9 2004/11/28 20:24:51 deraadt Exp $"; #endif #endif /* not lint */ @@ -63,8 +63,9 @@ static int fd = -1; void ftpdlogwtmp(char *line, char *name, char *host) { - struct utmp ut; + struct timeval tv; struct stat buf; + struct utmp ut; if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) return; @@ -72,7 +73,8 @@ ftpdlogwtmp(char *line, char *name, char *host) (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); - (void)time(&ut.ut_time); + gettimeofday(&tv, NULL); + ut.ut_time = tv.tv_sec; if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); |