From owner-freebsd-bugs Tue Jan 11 19: 0:15 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 4029515467 for ; Tue, 11 Jan 2000 19:00:08 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id TAA56082; Tue, 11 Jan 2000 19:00:08 -0800 (PST) (envelope-from gnats@FreeBSD.org) Date: Tue, 11 Jan 2000 19:00:08 -0800 (PST) Message-Id: <200001120300.TAA56082@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: John Polstra Subject: Re: bin/4238 - chpass time delay sensitivity [PATCH] Reply-To: John Polstra Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/4238; it has been noted by GNATS. From: John Polstra To: Daniel Hagan Cc: freebsd-gnats-submit@freebsd.org Subject: Re: bin/4238 - chpass time delay sensitivity [PATCH] Date: Tue, 11 Jan 2000 18:53:37 -0800 (PST) Daniel Hagan wrote: > Ok, given that the nsec granularity isn't available, would a work-around > like this be more appropriate? BTW, a context diff would have been nice. :-) > > Daniel > > Index: edit.c > =================================================================== > RCS file: /src/cvs/src/usr.bin/chpass/edit.c,v > retrieving revision 1.16 > diff -r1.16 edit.c > 41a42 >> #include > 67a69 >> struct timeval temp_time[2]; > 69a72,81 >> /* >> * Avoid race condition when user edits file in under a >> * second by back-dating file. >> */ >> gettimeofday(&(temp_time[0]), NULL); >> gettimeofday(&(temp_time[1]), NULL); >> temp_time[1].tv_sec--; >> if (utimes(tempname, temp_time)) >> pw_error(tempname, 1, 1); >> I can't decide whether you should be ridiculed mercilessly for this disgusting hack, or hailed as a genuine genius. :-) I would rule it out in an instant, except that the file's only a temporary file anyway. I guess it's OK, but don't tell anybody I said so. Minor style nit: you should remove the redundant parentheses in the gettimeofday() calls. gettimeofday(&temp_time[0], NULL); gettimeofday(&temp_time[1], NULL); If you don't do it, Bruce will. John To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message