Comment 3 for bug 871438

Revision history for this message
Elan Ruusamäe (glen666) wrote :

glad to hear!

but i'd still like to comment:

removing file and creating again under same filename is not secure. it is still open to race condition attacks.

attacker could repeatedly ln -s the path you unlinked and he has still chance to win if he slipped between removal and and creation file by main process. that's the race condition is all about.

http://en.wikipedia.org/wiki/Time-of-check-to-time-of-use
http://linux.die.net/man/1/mktemp

mktemp and friends do additional checks to ensure that the tempfile being created is their own.