[460] in bugtraq
Re: Race conditions, mkstemp
daemon@ATHENA.MIT.EDU (Casper Dik)
Sun Dec 11 09:10:49 1994
To: "Jonathan M. Bresler" <jmb@kryten.Atinc.COM>
Cc: bugtraq@fc.net
In-Reply-To: Your message of "Sat, 10 Dec 1994 20:26:17 EST."
<Pine.3.89.9412102011.D13777-0100000@kryten.atinc.com>
Date: Sun, 11 Dec 1994 14:07:02 +0100
From: Casper Dik <casper@fwi.uva.nl>
>
> here is the source for mkstemp from csrg. note the filesystem
>must support exclusive file locking atomic to the open() for this to be
>helpful. as is written in the mkstemp() man page.
>
> why wasnt O_TRUNC included. that would hammer both soft and hard links
Because it serves no useful purpose. A file created with O_EXCL|O_CREAT
will have 0 lenght. If the file needs to be truncated (O_TRUNC) it
already exists, but i that case the open w/ O_CREATE|O_EXCL would fail.
O_CREATE|O_TRUNC|O_EXCL makes no sense.
Casper