summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolar Designer <solar@openwall.com>2004-01-26 04:22:18 +0300
committerNicholas Clark <nick@ccl4.org>2004-04-04 13:50:28 +0000
commit11af7da0e1d7a0988d1541c27d48a30f8f4b7ab3 (patch)
tree22db0f1a94352a9386f5c0967a8096551cc66344
parent3a742c54898b1dc482b47074647fb7e89b5506f0 (diff)
downloadperl-11af7da0e1d7a0988d1541c27d48a30f8f4b7ab3.tar.gz
Integrate:
(the non dual-life modules from:) [ 22258] Subject: Re: [perl #15063] /tmp issues Message-ID: <20040125222218.GA13499@openwall.com> Remove insecure usage of /tmp from code and documentation [ 22409] Bump version numbers of moules affected by change #22258 (removing /tmp and other insecurities) [ 22642] Bump version numbers for modules that have changed since 5.8.3 p4raw-link: @22642 on //depot/perl: 20a6717b3f0310570b661870c2455994a4ab8016 p4raw-link: @22409 on //depot/perl: 97b11a4791ec0e8fc4d06eacad1050c1ccfa6a74 p4raw-link: @22258 on //depot/perl: 2359510ddb135dcc6e80153f51cff0a97b20b597 p4raw-id: //depot/maint-5.8/perl@22644 p4raw-edited: from //depot/perl@22643 'edit in' ext/B/B/Deparse.pm (@22357..) lib/ExtUtils/MM_NW5.pm (@22476..) p4raw-integrated: from //depot/perl@22643 'copy in' lib/dotsh.pl (@3759..) pod/perldbmfilter.pod (@12338..) mpeix/relink (@15590..) pod/perl571delta.pod (@17055..) mpeix/nm (@17582..) ext/ODBM_File/ODBM_File.xs (@17761..) utils/c2ph.PL (@19837..) ext/POSIX/POSIX.pod (@20081..) pod/perldebug.pod (@20202..) ext/IO/t/io_unix.t (@20268..) ext/ODBM_File/ODBM_File.pm (@20704..) pod/perlipc.pod (@20813..) pod/perlfaq8.pod (@21283..) pod/perlfaq5.pod (@21835..) pod/perlobj.pod (@22037..) pod/perl58delta.pod (@22100..) ext/B/B/Assembler.pm (@22107..) ext/DynaLoader/DynaLoader_pm.PL (@22191..) lib/base.pm (@22208..) lib/Shell.pm (@22259..) lib/Unicode/UCD.pm (@22295..) ext/IO/lib/IO/Handle.pm ext/IO/lib/IO/Pipe.pm (@22322..) lib/utf8.pm (@22430..) lib/IPC/Open3.pm (@22609..) 'edit in' ext/threads/threads.pm (@22218..) 'merge in' pod/perllexwarn.pod (@19808..) lib/ExtUtils/Liblist/Kid.pm lib/ExtUtils/MM_Win95.pm (@22322..) p4raw-integrated: from //depot/perl@22258 'copy in' perly.fixer (@18282..) 'merge in' pod/perlopentut.pod (@21040..) pod/perlop.pod (@22108..) pod/perlfunc.pod (@22252..)
-rw-r--r--ext/B/B/Assembler.pm2
-rw-r--r--ext/B/B/Deparse.pm4
-rw-r--r--ext/DynaLoader/DynaLoader_pm.PL2
-rw-r--r--ext/IO/lib/IO/Handle.pm2
-rw-r--r--ext/IO/lib/IO/Pipe.pm2
-rw-r--r--ext/IO/t/io_unix.t4
-rw-r--r--ext/ODBM_File/ODBM_File.pm2
-rw-r--r--ext/ODBM_File/ODBM_File.xs2
-rw-r--r--ext/POSIX/POSIX.pod10
-rwxr-xr-xext/threads/threads.pm6
-rw-r--r--lib/ExtUtils/Liblist/Kid.pm2
-rw-r--r--lib/ExtUtils/MM_NW5.pm4
-rw-r--r--lib/ExtUtils/MM_Win95.pm2
-rw-r--r--lib/IPC/Open3.pm2
-rw-r--r--lib/Shell.pm4
-rw-r--r--lib/Unicode/UCD.pm2
-rw-r--r--lib/base.pm2
-rw-r--r--lib/dotsh.pl12
-rw-r--r--lib/utf8.pm2
-rwxr-xr-xmpeix/nm6
-rwxr-xr-xmpeix/relink2
-rwxr-xr-xperly.fixer2
-rw-r--r--pod/perl571delta.pod8
-rw-r--r--pod/perl58delta.pod8
-rw-r--r--pod/perldbmfilter.pod4
-rw-r--r--pod/perldebug.pod2
-rw-r--r--pod/perlfaq5.pod7
-rw-r--r--pod/perlfaq8.pod10
-rw-r--r--pod/perlfunc.pod2
-rw-r--r--pod/perlipc.pod4
-rw-r--r--pod/perllexwarn.pod4
-rw-r--r--pod/perlobj.pod18
-rw-r--r--pod/perlop.pod6
-rw-r--r--pod/perlopentut.pod8
-rw-r--r--utils/c2ph.PL24
35 files changed, 100 insertions, 83 deletions
diff --git a/ext/B/B/Assembler.pm b/ext/B/B/Assembler.pm
index fce3753dce..6f6addf3b0 100644
--- a/ext/B/B/Assembler.pm
+++ b/ext/B/B/Assembler.pm
@@ -16,7 +16,7 @@ no warnings; # XXX
@ISA = qw(Exporter);
@EXPORT_OK = qw(assemble_fh newasm endasm assemble asm);
-$VERSION = 0.06;
+$VERSION = 0.07;
use strict;
my %opnumber;
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index 88f3d773d6..2c51249477 100644
--- a/ext/B/B/Deparse.pm
+++ b/ext/B/B/Deparse.pm
@@ -19,7 +19,9 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
CVf_METHOD CVf_LOCKED CVf_LVALUE
PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_SKIPWHITE
PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED);
-$VERSION = 0.64;
+# Not sure if I really should have this as maint's version, given that Deparse
+# differs from blead. (latter has // support)
+$VERSION = 0.66;
use strict;
use vars qw/$AUTOLOAD/;
use warnings ();
diff --git a/ext/DynaLoader/DynaLoader_pm.PL b/ext/DynaLoader/DynaLoader_pm.PL
index 270cd7e02f..e4a1ba8618 100644
--- a/ext/DynaLoader/DynaLoader_pm.PL
+++ b/ext/DynaLoader/DynaLoader_pm.PL
@@ -29,7 +29,7 @@ package DynaLoader;
use vars qw($VERSION *AUTOLOAD);
-$VERSION = '1.04'; # avoid typo warning
+$VERSION = '1.05'; # avoid typo warning
require AutoLoader;
*AUTOLOAD = \&AutoLoader::AUTOLOAD;
diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm
index 0c65de6007..4bb8ddf5b5 100644
--- a/ext/IO/lib/IO/Handle.pm
+++ b/ext/IO/lib/IO/Handle.pm
@@ -262,7 +262,7 @@ use IO (); # Load the XS module
require Exporter;
@ISA = qw(Exporter);
-$VERSION = "1.23";
+$VERSION = "1.24";
$VERSION = eval $VERSION;
@EXPORT_OK = qw(
diff --git a/ext/IO/lib/IO/Pipe.pm b/ext/IO/lib/IO/Pipe.pm
index d368500b44..1d43b6e904 100644
--- a/ext/IO/lib/IO/Pipe.pm
+++ b/ext/IO/lib/IO/Pipe.pm
@@ -14,7 +14,7 @@ our($VERSION);
use Carp;
use Symbol;
-$VERSION = "1.122";
+$VERSION = "1.123";
sub new {
my $type = shift;
diff --git a/ext/IO/t/io_unix.t b/ext/IO/t/io_unix.t
index 60520d1e41..e0a742f99d 100644
--- a/ext/IO/t/io_unix.t
+++ b/ext/IO/t/io_unix.t
@@ -24,7 +24,7 @@ BEGIN {
elsif ($^O eq 'os2') {
require IO::Socket;
- eval {IO::Socket::pack_sockaddr_un('/tmp/foo') || 1}
+ eval {IO::Socket::pack_sockaddr_un('/foo/bar') || 1}
or $@ !~ /not implemented/ or
$reason = 'compiled without TCP/IP stack v4';
} elsif ($^O =~ m/^(?:qnx|nto|vos)$/ ) {
@@ -37,7 +37,7 @@ BEGIN {
}
}
-$PATH = "/tmp/sock-$$";
+$PATH = "sock-$$";
# Test if we can create the file within the tmp directory
if (-e $PATH or not open(TEST, ">$PATH") and $^O ne 'os2') {
diff --git a/ext/ODBM_File/ODBM_File.pm b/ext/ODBM_File/ODBM_File.pm
index c14954cdaa..e9bdce5c69 100644
--- a/ext/ODBM_File/ODBM_File.pm
+++ b/ext/ODBM_File/ODBM_File.pm
@@ -7,7 +7,7 @@ require Tie::Hash;
use XSLoader ();
our @ISA = qw(Tie::Hash);
-our $VERSION = "1.04";
+our $VERSION = "1.05";
XSLoader::load 'ODBM_File', $VERSION;
diff --git a/ext/ODBM_File/ODBM_File.xs b/ext/ODBM_File/ODBM_File.xs
index fb3b5740ec..95dedfff9d 100644
--- a/ext/ODBM_File/ODBM_File.xs
+++ b/ext/ODBM_File/ODBM_File.xs
@@ -32,7 +32,7 @@ datum nextkey(datum key);
* Set DBM_BUG_DUPLICATE_FREE in the extension hint file.
*/
/* Close the previous dbm, and fail to open a new dbm */
-#define dbmclose() ((void) dbminit("/tmp/x/y/z/z/y"))
+#define dbmclose() ((void) dbminit("/non/exist/ent"))
#endif
#include <fcntl.h>
diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod
index 598464d3fc..03a5aa3a5d 100644
--- a/ext/POSIX/POSIX.pod
+++ b/ext/POSIX/POSIX.pod
@@ -417,9 +417,9 @@ Retrieves the value of a configurable limit on a file or directory. This
uses file descriptors such as those obtained by calling C<POSIX::open>.
The following will determine the maximum length of the longest allowable
-pathname on the filesystem which holds C</tmp/foo>.
+pathname on the filesystem which holds C</var/foo>.
- $fd = POSIX::open( "/tmp/foo", &POSIX::O_RDONLY );
+ $fd = POSIX::open( "/var/foo", &POSIX::O_RDONLY );
$path_max = POSIX::fpathconf( $fd, &POSIX::_PC_PATH_MAX );
Returns C<undef> on failure.
@@ -919,7 +919,7 @@ See also L<perlfunc/sysopen>.
Open a directory for reading.
- $dir = POSIX::opendir( "/tmp" );
+ $dir = POSIX::opendir( "/var" );
@files = POSIX::readdir( $dir );
POSIX::closedir( $dir );
@@ -930,9 +930,9 @@ Returns C<undef> on failure.
Retrieves the value of a configurable limit on a file or directory.
The following will determine the maximum length of the longest allowable
-pathname on the filesystem which holds C</tmp>.
+pathname on the filesystem which holds C</var>.
- $path_max = POSIX::pathconf( "/tmp", &POSIX::_PC_PATH_MAX );
+ $path_max = POSIX::pathconf( "/var", &POSIX::_PC_PATH_MAX );
Returns C<undef> on failure.
diff --git a/ext/threads/threads.pm b/ext/threads/threads.pm
index f7e44f7de8..d2448a17dd 100755
--- a/ext/threads/threads.pm
+++ b/ext/threads/threads.pm
@@ -50,7 +50,13 @@ our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
async
);
+>>>> ORIGINAL threads.pm#37
+our $VERSION = '1.02';
+==== THEIRS threads.pm#38
+our $VERSION = '1.03';
+==== YOURS threads.pm
our $VERSION = '1.01';
+<<<<
# || 0 to ensure compatibility with previous versions
diff --git a/lib/ExtUtils/Liblist/Kid.pm b/lib/ExtUtils/Liblist/Kid.pm
index 64d921304a..0c624aa545 100644
--- a/lib/ExtUtils/Liblist/Kid.pm
+++ b/lib/ExtUtils/Liblist/Kid.pm
@@ -10,7 +10,7 @@ use 5.00503;
use strict;
use vars qw($VERSION);
-$VERSION = 1.30;
+$VERSION = 1.30_01;
use Config;
use Cwd 'cwd';
diff --git a/lib/ExtUtils/MM_NW5.pm b/lib/ExtUtils/MM_NW5.pm
index 6144c2f16f..8b35183b92 100644
--- a/lib/ExtUtils/MM_NW5.pm
+++ b/lib/ExtUtils/MM_NW5.pm
@@ -23,7 +23,9 @@ use Config;
use File::Basename;
use vars qw(@ISA $VERSION);
-$VERSION = '2.06';
+# Has same version as blead, but differs. Must resync when next CPAN release
+# of MM is merged from blead to maint
+$VERSION = '2.07_02';
require ExtUtils::MM_Win32;
@ISA = qw(ExtUtils::MM_Win32);
diff --git a/lib/ExtUtils/MM_Win95.pm b/lib/ExtUtils/MM_Win95.pm
index 2c14396d2d..808191896d 100644
--- a/lib/ExtUtils/MM_Win95.pm
+++ b/lib/ExtUtils/MM_Win95.pm
@@ -1,7 +1,7 @@
package ExtUtils::MM_Win95;
use vars qw($VERSION @ISA);
-$VERSION = 0.03;
+$VERSION = 0.03_01;
require ExtUtils::MM_Win32;
@ISA = qw(ExtUtils::MM_Win32);
diff --git a/lib/IPC/Open3.pm b/lib/IPC/Open3.pm
index 8636c33b6d..da925182e7 100644
--- a/lib/IPC/Open3.pm
+++ b/lib/IPC/Open3.pm
@@ -9,7 +9,7 @@ require Exporter;
use Carp;
use Symbol qw(gensym qualify);
-$VERSION = 1.0105;
+$VERSION = 1.0106;
@ISA = qw(Exporter);
@EXPORT = qw(open3);
diff --git a/lib/Shell.pm b/lib/Shell.pm
index 1f58b0582c..a89db69288 100644
--- a/lib/Shell.pm
+++ b/lib/Shell.pm
@@ -6,7 +6,7 @@ use File::Spec::Functions;
our($capture_stderr, $VERSION, $AUTOLOAD);
-$VERSION = '0.5.1';
+$VERSION = '0.5.2';
sub new { bless \my $foo, shift }
sub DESTROY { }
@@ -147,7 +147,7 @@ Here's one that'll whack your mind a little out.
sub ps;
print ps -ww;
- cp("/etc/passwd", "/tmp/passwd");
+ cp("/etc/passwd", "/etc/passwd.orig");
That's maybe too gonzo. It actually exports an AUTOLOAD to the current
package (and uncovered a bug in Beta 3, by the way). Maybe the usual
diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm
index cce547bca4..dfdd2dcb51 100644
--- a/lib/Unicode/UCD.pm
+++ b/lib/Unicode/UCD.pm
@@ -3,7 +3,7 @@ package Unicode::UCD;
use strict;
use warnings;
-our $VERSION = '0.21';
+our $VERSION = '0.22';
use Storable qw(dclone);
diff --git a/lib/base.pm b/lib/base.pm
index b735848f9b..cc0d3c6e6d 100644
--- a/lib/base.pm
+++ b/lib/base.pm
@@ -2,7 +2,7 @@ package base;
use strict 'vars';
use vars qw($VERSION);
-$VERSION = '2.04';
+$VERSION = '2.05';
# constant.pm is slow
sub SUCCESS () { 1 }
diff --git a/lib/dotsh.pl b/lib/dotsh.pl
index 5be2413ae6..810ebc4d60 100644
--- a/lib/dotsh.pl
+++ b/lib/dotsh.pl
@@ -27,9 +27,9 @@
# dependent upon. These variables MUST be defined using shell syntax.
#
# Example:
-# &dotsh ('/tmp/foo', 'arg1');
-# &dotsh ('/tmp/foo');
-# &dotsh ('/tmp/foo arg1 ... argN');
+# &dotsh ('/foo/bar', 'arg1');
+# &dotsh ('/foo/bar');
+# &dotsh ('/foo/bar arg1 ... argN');
#
sub dotsh {
local(@sh) = @_;
@@ -54,19 +54,17 @@ sub dotsh {
}
}
if (length($vars) > 0) {
- system "$shell \"$vars;. $command $args; set > /tmp/_sh_env$$\"";
+ open (_SH_ENV, "$shell \"$vars && . $command $args && set \" |") || die;
} else {
- system "$shell \". $command $args; set > /tmp/_sh_env$$\"";
+ open (_SH_ENV, "$shell \". $command $args && set \" |") || die;
}
- open (_SH_ENV, "/tmp/_sh_env$$") || die "Could not open /tmp/_sh_env$$!\n";
while (<_SH_ENV>) {
chop;
m/^([^=]*)=(.*)/s;
$ENV{$1} = $2;
}
close (_SH_ENV);
- system "rm -f /tmp/_sh_env$$";
foreach $key (keys(%ENV)) {
$tmp .= "\$$key = \$ENV{'$key'};" if $key =~ /^[A-Za-z]\w*$/;
diff --git a/lib/utf8.pm b/lib/utf8.pm
index ea99dd9f86..486a4faa88 100644
--- a/lib/utf8.pm
+++ b/lib/utf8.pm
@@ -2,7 +2,7 @@ package utf8;
$utf8::hint_bits = 0x00800000;
-our $VERSION = '1.02';
+our $VERSION = '1.03';
sub import {
$^H |= $utf8::hint_bits;
diff --git a/mpeix/nm b/mpeix/nm
index e2a5d27c25..64e58be4d8 100755
--- a/mpeix/nm
+++ b/mpeix/nm
@@ -22,12 +22,12 @@ esac
# I wanted to pipe this into awk, but it fell victim to a known pipe/streams
# bug on my multiprocessor machine.
-callci xeq linkedit.pub.sys \"$LIST\" >/tmp/nm.$$
+callci xeq linkedit.pub.sys \"$LIST\" >nm.$$
/bin/awk '\
/ data univ / { printf "%-20s|%10s|%-6s|%-7s|%s\n",$1,$5,"extern","data","?"} \
- / entry univ / { printf "%-20s|%10s|%-6s|%-7s|%s\n",$1,$7,"extern","entry","?"}' /tmp/nm.$$
+ / entry univ / { printf "%-20s|%10s|%-6s|%-7s|%s\n",$1,$7,"extern","entry","?"}' nm.$$
-rm -f /tmp/nm.$$
+rm -f nm.$$
exit 0
diff --git a/mpeix/relink b/mpeix/relink
index 0ba9aebada..ec37142194 100755
--- a/mpeix/relink
+++ b/mpeix/relink
@@ -14,7 +14,7 @@ RAND=/$HPACCOUNT/$HPGROUP/libcrand
echo "Creating $RAND.sl...\n"
-TEMP=/tmp/perlmpe.$$
+TEMP=perlmpe.$$
rm -f $TEMP $RAND.a $RAND.sl
diff --git a/perly.fixer b/perly.fixer
index b627a8c2bd..fec981f208 100755
--- a/perly.fixer
+++ b/perly.fixer
@@ -23,7 +23,7 @@ gnupatch=patch
input=$1
output=$2
-tmp=/tmp/f$$
+tmp=perly$$
inputh=`echo $input|sed 's:\.c$:.h:'`
if grep '^#ifdef PERL_CORE' $inputh; then
diff --git a/pod/perl571delta.pod b/pod/perl571delta.pod
index 431c35928b..aff02e5add 100644
--- a/pod/perl571delta.pod
+++ b/pod/perl571delta.pod
@@ -771,17 +771,17 @@ SOCKS support is now much more robust.
If your file system supports symbolic links you can build Perl outside
of the source directory by
- mkdir /tmp/perl/build/directory
- cd /tmp/perl/build/directory
+ mkdir perl/build/directory
+ cd perl/build/directory
sh /path/to/perl/source/Configure -Dmksymlinks ...
-This will create in /tmp/perl/build/directory a tree of symbolic links
+This will create in perl/build/directory a tree of symbolic links
pointing to files in /path/to/perl/source. The original files are left
unaffected. After Configure has finished you can just say
make all test
-and Perl will be built and tested, all in /tmp/perl/build/directory.
+and Perl will be built and tested, all in perl/build/directory.
=back
diff --git a/pod/perl58delta.pod b/pod/perl58delta.pod
index b37157f9a0..9d955ef8a4 100644
--- a/pod/perl58delta.pod
+++ b/pod/perl58delta.pod
@@ -1905,17 +1905,17 @@ for site-wide changes).
If your file system supports symbolic links, you can build Perl outside
of the source directory by
- mkdir /tmp/perl/build/directory
- cd /tmp/perl/build/directory
+ mkdir perl/build/directory
+ cd perl/build/directory
sh /path/to/perl/source/Configure -Dmksymlinks ...
-This will create in /tmp/perl/build/directory a tree of symbolic links
+This will create in perl/build/directory a tree of symbolic links
pointing to files in /path/to/perl/source. The original files are left
unaffected. After Configure has finished, you can just say
make all test
-and Perl will be built and tested, all in /tmp/perl/build/directory.
+and Perl will be built and tested, all in perl/build/directory.
[561]
=item *
diff --git a/pod/perldbmfilter.pod b/pod/perldbmfilter.pod
index 8384999e6a..d62e496f9f 100644
--- a/pod/perldbmfilter.pod
+++ b/pod/perldbmfilter.pod
@@ -91,7 +91,7 @@ fix very easily.
use Fcntl ;
my %hash ;
- my $filename = "/tmp/filt" ;
+ my $filename = "filt" ;
unlink $filename ;
my $db = tie(%hash, 'SDBM_File', $filename, O_RDWR|O_CREAT, 0640)
@@ -137,7 +137,7 @@ Here is a DBM Filter that does it:
use warnings ;
use DB_File ;
my %hash ;
- my $filename = "/tmp/filt" ;
+ my $filename = "filt" ;
unlink $filename ;
diff --git a/pod/perldebug.pod b/pod/perldebug.pod
index ee9fa97d1c..e44eaafdcb 100644
--- a/pod/perldebug.pod
+++ b/pod/perldebug.pod
@@ -700,7 +700,7 @@ This module should implement a method named C<new> that returns an object
with two methods: C<IN> and C<OUT>. These should return filehandles to use
for debugging input and output correspondingly. The C<new> method should
inspect an argument containing the value of C<$ENV{PERLDB_NOTTY}> at
-startup, or C<"/tmp/perldbtty$$"> otherwise. This file is not
+startup, or C<".perldbtty$$"> otherwise. This file is not
inspected for proper ownership, so security hazards are theoretically
possible.
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:
diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod
index 2fceab143f..e2cc1faa90 100644
--- a/pod/perlfaq8.pod
+++ b/pod/perlfaq8.pod
@@ -749,10 +749,10 @@ but leave its STDOUT to come out our old STDERR:
while (<PH>) { } # plus a read
To read both a command's STDOUT and its STDERR separately, it's easiest
-and safest to redirect them separately to files, and then read from those
-files when the program is done:
+to redirect them separately to files, and then read from those files
+when the program is done:
- system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr");
+ system("program args 1>program.stdout 2>program.stderr");
Ordering is important in all these examples. That's because the shell
processes file descriptor redirections in strictly left to right order.
@@ -1063,8 +1063,8 @@ O_NDELAY or O_NONBLOCK flag from the Fcntl module in conjunction with
sysopen():
use Fcntl;
- sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT, 0644)
- or die "can't open /tmp/somefile: $!":
+ sysopen(FH, "/foo/somefile", O_WRONLY|O_NDELAY|O_CREAT, 0644)
+ or die "can't open /foo/somefile: $!":
=head2 How do I install a module from CPAN?
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index afcde4faa6..24dd44fe97 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -2932,7 +2932,7 @@ Examples:
open(ARTICLE, "caesar <$article |") # ditto
or die "Can't start caesar: $!";
- open(EXTRACT, "|sort >/tmp/Tmp$$") # $$ is our process id
+ open(EXTRACT, "|sort >Tmp$$") # $$ is our process id
or die "Can't start sort: $!";
# in memory files
diff --git a/pod/perlipc.pod b/pod/perlipc.pod
index 5f8af22550..c25eb878dc 100644
--- a/pod/perlipc.pod
+++ b/pod/perlipc.pod
@@ -1030,7 +1030,7 @@ Here's a sample Unix-domain client:
use strict;
my ($rendezvous, $line);
- $rendezvous = shift || '/tmp/catsock';
+ $rendezvous = shift || 'catsock';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
connect(SOCK, sockaddr_un($rendezvous)) || die "connect: $!";
while (defined($line = <SOCK>)) {
@@ -1051,7 +1051,7 @@ to be on the localhost, and thus everything works right.
sub spawn; # forward declaration
sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
- my $NAME = '/tmp/catsock';
+ my $NAME = 'catsock';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
diff --git a/pod/perllexwarn.pod b/pod/perllexwarn.pod
index 8ee7fc3248..911de2b72e 100644
--- a/pod/perllexwarn.pod
+++ b/pod/perllexwarn.pod
@@ -381,9 +381,9 @@ Consider the module C<MyMod::Abc> below.
sub open {
my $path = shift ;
if ($path !~ m#^/#) {
- warnings::warn("changing relative path to /tmp/")
+ warnings::warn("changing relative path to /var/abc")
if warnings::enabled();
- $path = "/tmp/$path" ;
+ $path = "/var/abc/$path";
}
}
diff --git a/pod/perlobj.pod b/pod/perlobj.pod
index 156a0b8506..7d7beaf477 100644
--- a/pod/perlobj.pod
+++ b/pod/perlobj.pod
@@ -535,15 +535,15 @@ two-phased garbage collection:
warn "time to die...";
exit;
-When run as F</tmp/test>, the following output is produced:
-
- starting program at /tmp/test line 18.
- CREATING SCALAR(0x8e5b8) at /tmp/test line 7.
- CREATING SCALAR(0x8e57c) at /tmp/test line 7.
- leaving block at /tmp/test line 23.
- DESTROYING Subtle=SCALAR(0x8e5b8) at /tmp/test line 13.
- just exited block at /tmp/test line 26.
- time to die... at /tmp/test line 27.
+When run as F</foo/test>, the following output is produced:
+
+ starting program at /foo/test line 18.
+ CREATING SCALAR(0x8e5b8) at /foo/test line 7.
+ CREATING SCALAR(0x8e57c) at /foo/test line 7.
+ leaving block at /foo/test line 23.
+ DESTROYING Subtle=SCALAR(0x8e5b8) at /foo/test line 13.
+ just exited block at /foo/test line 26.
+ time to die... at /foo/test line 27.
DESTROYING Subtle=SCALAR(0x8e57c) during global destruction.
Notice that "global destruction" bit there? That's the thread
diff --git a/pod/perlop.pod b/pod/perlop.pod
index 8529387814..eff13a2c5a 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -1162,10 +1162,10 @@ but leave its STDOUT to come out the old STDERR:
$output = `cmd 3>&1 1>&2 2>&3 3>&-`;
To read both a command's STDOUT and its STDERR separately, it's easiest
-and safest to redirect them separately to files, and then read from those
-files when the program is done:
+to redirect them separately to files, and then read from those files
+when the program is done:
- system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr");
+ system("program args 1>program.stdout 2>program.stderr");
Using single-quote as a delimiter protects the command from Perl's
double-quote interpolation, passing it on to the shell instead:
diff --git a/pod/perlopentut.pod b/pod/perlopentut.pod
index 9d740b2342..3116f785c1 100644
--- a/pod/perlopentut.pod
+++ b/pod/perlopentut.pod
@@ -192,11 +192,11 @@ whether it only works on existing files or always clobbers existing ones.
open(WTMP, "+< /usr/adm/wtmp")
|| die "can't open /usr/adm/wtmp: $!";
- open(SCREEN, "+> /tmp/lkscreen")
- || die "can't open /tmp/lkscreen: $!";
+ open(SCREEN, "+> lkscreen")
+ || die "can't open lkscreen: $!";
- open(LOGFILE, "+>> /tmp/applog"
- || die "can't open /tmp/applog: $!";
+ open(LOGFILE, "+>> /var/log/applog"
+ || die "can't open /var/log/applog: $!";
The first one won't create a new file, and the second one will always
clobber an old one. The third one will create a new file if necessary
diff --git a/utils/c2ph.PL b/utils/c2ph.PL
index 91ecc04552..9cb89376cf 100644
--- a/utils/c2ph.PL
+++ b/utils/c2ph.PL
@@ -280,6 +280,7 @@ Anyway, here it is. Should run on perl v4 or greater. Maybe less.
$RCSID = '$Id: c2ph,v 1.7 95/10/28 10:41:47 tchrist Exp Locker: tchrist $';
+use File::Temp;
######################################################################
@@ -480,6 +481,13 @@ sub defvar {
printf "%-16s%-15s %s\n", $var, eval "\$$var", $msg;
}
+sub safedir {
+ $SAFEDIR = File::Temp::tempdir("c2ph.XXXXXX", TMPDIR => 1, CLEANUP => 1)
+ unless (defined($SAFEDIR));
+}
+
+undef $SAFEDIR;
+
$recurse = 1;
if (@ARGV) {
@@ -495,15 +503,15 @@ if (@ARGV) {
}
elsif (@ARGV == 1 && $ARGV[0] =~ /\.c$/) {
local($dir, $file) = $ARGV[0] =~ m#(.*/)?(.*)$#;
- $chdir = "cd $dir; " if $dir;
+ $chdir = "cd $dir && " if $dir;
&system("$chdir$CC $CFLAGS $DEFINES $file") && exit 1;
$ARGV[0] =~ s/\.c$/.s/;
}
else {
- $TMPDIR = tempdir(CLEANUP => 1);
- $TMP = "$TMPDIR/c2ph.$$.c";
+ &safedir;
+ $TMP = "$SAFEDIR/c2ph.$$.c";
&system("cat @ARGV > $TMP") && exit 1;
- &system("cd $TMPDIR; $CC $CFLAGS $DEFINES $TMP") && exit 1;
+ &system("cd $SAFEDIR && $CC $CFLAGS $DEFINES $TMP") && exit 1;
unlink $TMP;
$TMP =~ s/\.c$/.s/;
@ARGV = ($TMP);
@@ -1274,8 +1282,8 @@ sub fetch_template {
}
sub compute_intrinsics {
- $TMPDIR ||= tempdir(CLEANUP => 1);
- local($TMP) = "$TMPDIR/c2ph-i.$$.c";
+ &safedir;
+ local($TMP) = "$SAFEDIR/c2ph-i.$$.c";
open (TMP, ">$TMP") || die "can't open $TMP: $!";
select(TMP);
@@ -1303,7 +1311,7 @@ EOF
close TMP;
select(STDOUT);
- open(PIPE, "cd $TMPDIR && $CC $TMP && $TMPDIR/a.out|");
+ open(PIPE, "cd $SAFEDIR && $CC $TMP && $SAFEDIR/a.out|");
while (<PIPE>) {
chop;
split(' ',$_,2);;
@@ -1312,7 +1320,7 @@ EOF
$intrinsics{$_[1]} = $template{$_[0]};
}
close(PIPE) || die "couldn't read intrinsics!";
- unlink($TMP, '$TMPDIR/a.out');
+ unlink($TMP, '$SAFEDIR/a.out');
print STDERR "done\n" if $trace;
}