Date: Tue, 11 Jan 2000 19:00:08 -0800 (PST) From: John Polstra <jdp@polstra.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/4238 - chpass time delay sensitivity [PATCH] Message-ID: <200001120300.TAA56082@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/4238; it has been noted by GNATS. From: John Polstra <jdp@polstra.com> To: Daniel Hagan <dhagan@cs.vt.edu> 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 <sys/time.h> > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001120300.TAA56082>