Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Mar 2002 22:14:22 +0100
From:      Jens Schweikhardt <schweikh@schweikhardt.net>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>, freebsd-audit@FreeBSD.ORG
Subject:   Re: crontab changes for PR bin/22612; please comment
Message-ID:  <20020322221422.A5487@schweikhardt.net>
In-Reply-To: <p05101525b8c10898deca@[128.113.24.47]>; from drosih@rpi.edu on Fri, Mar 22, 2002 at 11:16:15AM -0500
References:  <20020318130904.A3869@schweikhardt.net> <p05101502b8bc01b04024@[128.113.24.47]> <20020320192624.A1258@schweikhardt.net> <p0510151fb8be8b748a93@[128.113.24.47]> <20020320210458.A13393@uriah.heep.sax.de> <p05101525b8c10898deca@[128.113.24.47]>

next in thread | previous in thread | raw e-mail | index | archive | help
Folks,

On Fri, Mar 22, 2002 at 11:16:15AM -0500, Garance A Drosihn wrote:
# At 9:04 PM +0100 3/20/02, Joerg Wunsch wrote:
...
# >How about md5-checking the files?
# 
# Well, if it were me I would probably go with the lazy
# fix and add the 1-second sleep.  However, it probably
# would be even "nicer to the user" to do an md5-check.

I tried to also look at the tv_nsec field and usleep for just a few
ms, but to my dismay it's always 0. So I finally decided to go the
way Garance suggested. Any strong objections?

Index: crontab.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/cron/crontab/crontab.c,v
retrieving revision 1.18
diff -u -r1.18 crontab.c
--- crontab.c	9 Jul 2001 09:23:57 -0000	1.18
+++ crontab.c	22 Mar 2002 19:22:10 -0000
@@ -43,7 +43,7 @@
 #if defined(POSIX)
 # include <locale.h>
 #endif
-
+#include <unistd.h>
 
 #define NHEADER_LINES 3
 
@@ -381,6 +381,13 @@
 	if (statbuf.st_dev != fsbuf.st_dev || statbuf.st_ino != fsbuf.st_ino)
 		errx(ERROR_EXIT, "temp file must be edited in place");
 	mtime = statbuf.st_mtime;
+	/*
+	 * Nap for one second so the mtime is guaranteed to be less than the
+	 * mtime for the temp file we examine later on (in case of
+	 * modifications). We can't use the tv_nsec because some file systems
+	 * do not use it.
+	 */
+	sleep(1);
 
 	if ((!(editor = getenv("VISUAL")))
 	 && (!(editor = getenv("EDITOR")))


Regards,

	Jens
-- 
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020322221422.A5487>