From owner-freebsd-audit Fri Mar 22 13:13:36 2002 Delivered-To: freebsd-audit@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id 2DCC537B420 for ; Fri, 22 Mar 2002 13:13:28 -0800 (PST) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id 77D2A17D30; Fri, 22 Mar 2002 22:13:25 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.1/8.12.1/Debian -5) with UUCP id g2MLDPjf017007; Fri, 22 Mar 2002 22:13:25 +0100 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.2/8.11.6) id g2MLEN1t005639; Fri, 22 Mar 2002 22:14:23 +0100 (CET) (envelope-from schweikh) Date: Fri, 22 Mar 2002 22:14:22 +0100 From: Jens Schweikhardt To: Garance A Drosihn Cc: Joerg Wunsch , freebsd-audit@FreeBSD.ORG Subject: Re: crontab changes for PR bin/22612; please comment Message-ID: <20020322221422.A5487@schweikhardt.net> References: <20020318130904.A3869@schweikhardt.net> <20020320192624.A1258@schweikhardt.net> <20020320210458.A13393@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from drosih@rpi.edu on Fri, Mar 22, 2002 at 11:16:15AM -0500 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #endif - +#include #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