3/12 What is the best method for securely updating the contents of
file (unix/c)?
What I've got right now is open() then mkstemp() and copy the
bits from the old fd to the fd from mkstemp() and finally call
rename(). I've specified O_RDONLY|O_EXLOCK, which should prevent
two instances of the process from colliding, but I'm concerned
that the call to rename() may not be "safe". TIA.
\_ what is your definition of "secure"? What's wrong with more
obvious methods?
\_ race conditions.
\_ rename is atomic. what you describe should work fine. --aaron |