Paul Herman wrote:
> Fine, then lock them both, and use rename().  Patch attached.
> 
> In fact, if you look at fileupdate(), you see that it already gains
> an exclusive lock on the temp file, but not the original
> "/etc/master.passwd" (if you will.)  I think this is a bug, because
> the original is getting modified (at least in name space), so that
> should be locked while pw(8) is operating.
> 
> What do you think?

Don't use an exclusive open.  Use a standard lock file lock
mechanism.

The problem with your proposed patch is that it breaks the
ability to allow authentication against the database while
it is undergoing modification, which may be a prolonged period.

The correct way to deal with this is to make a hard link against
the file, verify that the link count is exactly 2, and if it's
not, back off and fail.

You are only permitted to write the file if you are the one that
made the second link.

Since both rename and link are atomic operations in the directory,
you are safe.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to