summaryrefslogtreecommitdiff
path: root/pod/perlfaq5.pod
diff options
context:
space:
mode:
authorSolar Designer <solar@openwall.com>2004-01-26 04:22:18 +0300
committerDave Mitchell <davem@fdisolutions.com>2004-02-01 17:40:02 +0000
commit2359510ddb135dcc6e80153f51cff0a97b20b597 (patch)
treeb074c5df813a1e3e529f0330620b456ecc4988e6 /pod/perlfaq5.pod
parenta95a5f75a0e72874474834cd9e274afa0f23b6d8 (diff)
downloadperl-2359510ddb135dcc6e80153f51cff0a97b20b597.tar.gz
Re: [perl #15063] /tmp issues
Message-ID: <20040125222218.GA13499@openwall.com> Remove insecure usage of /tmp from code and documentation p4raw-id: //depot/perl@22258
Diffstat (limited to 'pod/perlfaq5.pod')
-rw-r--r--pod/perlfaq5.pod7
1 files changed, 4 insertions, 3 deletions
diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod
index be10390120..49a348a81c 100644
--- a/pod/perlfaq5.pod
+++ b/pod/perlfaq5.pod
@@ -141,6 +141,7 @@ temporary files in one process, use a counter:
my $count = 0;
until (defined(fileno(FH)) || $count++ > 100) {
$base_name =~ s/-(\d+)$/"-" . (1 + $1)/e;
+ # O_EXCL is required for security reasons.
sysopen(FH, $base_name, O_WRONLY|O_EXCL|O_CREAT);
}
if (defined(fileno(FH))
@@ -427,8 +428,8 @@ To open file for update, file must not exist:
To open a file without blocking, creating if necessary:
- sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT)
- or die "can't open /tmp/somefile: $!":
+ sysopen(FH, "/foo/somefile", O_WRONLY|O_NDELAY|O_CREAT)
+ or die "can't open /foo/somefile: $!":
Be warned that neither creation nor deletion of files is guaranteed to
be an atomic operation over NFS. That is, two processes might both
@@ -924,7 +925,7 @@ There's also a File::Tail module from CPAN.
If you check L<perlfunc/open>, you'll see that several of the ways
to call open() should do the trick. For example:
- open(LOG, ">>/tmp/logfile");
+ open(LOG, ">>/foo/logfile");
open(STDERR, ">&LOG");
Or even with a literal numeric descriptor: