Re: crontab changes for PR bin/22612; please comment

Jens Schweikhardt <[email protected]>
Newsgroups gmane.os.freebsd.devel.audit
Message-ID <[email protected]>
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 [email protected]
with "unsubscribe freebsd-audit" in the body of the message
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.