System.IO.openTempFile secure?

Is the function System.IO.openTempFile secure in the sense that it picks the filename, tests for its existence, and creates it atomically? Either way, it's important that it's documented in Haddock, IMO. peace, isaac

Yes. It should be safe. The function generates a new file name and
then tries to create file with such name. If it succeded then the file
path and handle are returned. If the OS respond with EEXIST then the
function tries to generate new name.
Cheers,
Krasimir
On 5/10/05, Isaac Jones
Is the function System.IO.openTempFile secure in the sense that it picks the filename, tests for its existence, and creates it atomically? Either way, it's important that it's documented in Haddock, IMO.
peace,
isaac
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Krasimir Angelov wrote:
Is the function System.IO.openTempFile secure in the sense that it picks the filename, tests for its existence, and creates it atomically? Either way, it's important that it's documented in Haddock, IMO.
Yes. It should be safe. The function generates a new file name and then tries to create file with such name. If it succeded then the file path and handle are returned. If the OS respond with EEXIST then the function tries to generate new name.
It's as safe as open(O_CREAT|O_EXCL), i.e. safe on POSIX-conformant
filesystems, unsafe on e.g. NFS.
--
Glynn Clements
participants (3)
-
Glynn Clements
-
Isaac Jones
-
Krasimir Angelov