Date: Sun, 23 Jun 2002 12:04:52 -0500 From: "Matthew D. Fuller" <fullermd@over-yonder.net> To: Paul Herman <pherman@frenchfries.net> Cc: "Geoffrey C. Speicher" <geoff@sea-incorporated.com>, freebsd-hackers@FreeBSD.ORG Subject: Re: bug in pw, -STABLE [patch] Message-ID: <20020623170452.GG81018@over-yonder.net> In-Reply-To: <20020623094323.F38369-100000@mammoth.eat.frenchfries.net> References: <20020623160439.GE81018@over-yonder.net> <20020623094323.F38369-100000@mammoth.eat.frenchfries.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jun 23, 2002 at 09:59:10AM -0700 I heard the voice of Paul Herman, and lo! it spake thus: > > I can't imagine it would be too extensive of a rewrite. The temp > file code could be kept, and in fileupd.c:fileupdate() instead of > rename("/etc/master.passwd.new", "/etc/master.passwd"), it just > copies the contents of the .new file into the original file (that > has the O_EXLOCK.) Yes, but that would open up the problem that cause the rename(2) to be used in the first place; i.e., rename() is atomic; read(2)/write(2)'ing a bunch of data isn't, so a system crash at the wrong time would leave you with a partial master.passwd. It wouldn't be the end of the world, of course, since you'd still have the [s]pwd.db, so you could login, and you'd have the master.passwd.new, so you could recover, but you'd have to notice it and catch it before pw(8) or friends ran again. rename(2)'s guarantee is what saves you there. From the manpage: int rename(const char *from, const char *to); [...] Rename() guarantees that if to already exists, an instance of to will always exist, even if the system should crash in the middle of the opera- tion. -- Matthew Fuller (MF4839) | fullermd@over-yonder.net Systems/Network Administrator | http://www.over-yonder.net/~fullermd/ "The only reason I'm burning my candle at both ends, is because I haven't figured out how to light the middle yet" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020623170452.GG81018>