Date: Wed, 12 Jan 2000 05:50:01 -0800 (PST) From: Daniel Hagan <dhagan@cs.vt.edu> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/4238 - chpass time delay sensitivity [PATCH] Message-ID: <200001121350.FAA31156@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: Daniel Hagan <dhagan@cs.vt.edu> To: John Polstra <jdp@polstra.com> Cc: freebsd-gnats-submit@freebsd.org, jhb@freebsd.org Subject: Re: bin/4238 - chpass time delay sensitivity [PATCH] Date: Wed, 12 Jan 2000 08:45:03 -0500 (EST) On Tue, 11 Jan 2000, John Polstra wrote: > 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. I would vote for the disgusting hack category myself :). I was complaining to John Baldwin (jhb) about it, and he mentioned the work-around (I never would have thought of it, being too tied to my anti-disgusting-hack philosophy). It seems harmless enough in this special case, but I won't take it personally if someone cans the patch. > Minor style nit: you should remove the redundant parentheses in the > gettimeofday() calls. Ok, taken care of. Here's the updated diff (in context diff format even ;-)) Index: edit.c =================================================================== RCS file: /src/cvs/src/usr.bin/chpass/edit.c,v retrieving revision 1.16 diff -c -r1.16 edit.c *** edit.c 1999/12/21 19:30:09 1.16 --- edit.c 2000/01/12 13:31:30 *************** *** 39,44 **** --- 39,45 ---- #include <sys/param.h> #include <sys/stat.h> + #include <sys/time.h> #include <ctype.h> #include <err.h> *************** *** 65,72 **** --- 66,84 ---- struct passwd *pw; { struct stat begin, end; + struct timeval temp_time[2]; for (;;) { + /* + * 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); + if (stat(tempname, &begin)) pw_error(tempname, 1, 1); pw_edit(1); -- Daniel Hagan Computer Science CSE dhagan@cs.vt.edu http://www.cs.vt.edu/~dhagan/ 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?200001121350.FAA31156>