summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/crontab.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2007-11-17 16:09:29 +0000
committermillert <millert@openbsd.org>2007-11-17 16:09:29 +0000
commitbe27b01e326b51443435688f647ba5d73fe297d0 (patch)
tree7d9fe3bc3a4b81cada203d035a7830063aa2bcb1 /usr.sbin/cron/crontab.c
parentcvs header (diff)
downloadwireguard-openbsd-be27b01e326b51443435688f647ba5d73fe297d0.tar.xz
wireguard-openbsd-be27b01e326b51443435688f647ba5d73fe297d0.zip
Deal with timespec vs. timeval precision issues. Fixes a problem
where the "no changes" case was not properly detected due to timespec supporting nanosec resolution but timeval only supporting microsec resolution. OK deraadt@
Diffstat (limited to 'usr.sbin/cron/crontab.c')
-rw-r--r--usr.sbin/cron/crontab.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index f89b324b739..b2c97e84b82 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crontab.c,v 1.54 2007/10/17 20:02:33 deraadt Exp $ */
+/* $OpenBSD: crontab.c,v 1.55 2007/11/17 16:09:29 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@@ -21,7 +21,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-static char const rcsid[] = "$OpenBSD: crontab.c,v 1.54 2007/10/17 20:02:33 deraadt Exp $";
+static char const rcsid[] = "$OpenBSD: crontab.c,v 1.55 2007/11/17 16:09:29 millert Exp $";
/* crontab - install and manage per-user crontab files
* vix 02may87 [RCS has the rest of the log]
@@ -311,9 +311,13 @@ edit_cmd(void) {
perror("fstat");
goto fatal;
}
- memcpy(&mtimespec, &statbuf.st_mtimespec, sizeof(mtimespec));
+ /*
+ * Note that timespec has higher precision than timeval so we
+ * store mtimespec using timeval precision so we can compare later.
+ */
TIMESPEC_TO_TIMEVAL(&tv[0], &statbuf.st_atimespec);
TIMESPEC_TO_TIMEVAL(&tv[1], &statbuf.st_mtimespec);
+ TIMEVAL_TO_TIMESPEC(&tv[1], &mtimespec);
/* Turn off signals. */
(void)signal(SIGHUP, SIG_IGN);