Subject: | atomic tempfile() without OPEN |
Date: | Fri, 05 Apr 2019 16:39:07 +1100 |
To: | bug-File-Slurp [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
With File::Slurp 9999.26 and File::Temp 0.2304, a program
use File::Slurp;
write_file('/tmp/foo', {atomic => 1}, "hello");
run with "perl -w foo.pl" prints a warning
tempfile(): temporary filename requested but not opened.
Possibly unsafe, consider using tempfile() with OPEN set to true
This is from File::Temp. It's one of those blast every user messages,
but it's correct that an opened temp file avoids risks of clashes or
races (small risks).
If I'm not mistaken, write_file() wants an opened temp at that point,
if felt like letting tempfile() do it. I think a chmod() would be
needed to copy perms of the actual target.