From 6e1ab32be62cf833ebca72ac6cabcea2dcdc97bb Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 30 Nov 2013 17:11:06 +0000 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20use=20File::Temp=20because=20it?= =?UTF-8?q?=E2=80=99s=20Perl=20>=3D=205.6.1=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit spotted by RT --- check.pl | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/check.pl b/check.pl index ecd8f8d..3812041 100644 --- a/check.pl +++ b/check.pl @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.pl,v 1.32 2013/07/21 18:35:56 tg Exp $ +# $MirOS: src/bin/mksh/check.pl,v 1.33 2013/11/30 17:11:06 tg Exp $ # $OpenBSD: th,v 1.16 2013/06/14 20:52:08 millert Exp $ #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, @@ -172,7 +172,6 @@ BEGIN { use Getopt::Std; use Config; -use File::Temp qw/ :mktemp /; $os = defined $^O ? $^O : 'unknown'; @@ -251,7 +250,7 @@ die "$prog: no test set specified (use -s)\n" if !defined $opt_s; $test_prog = $opt_p; $verbose = defined $opt_v && $opt_v; $test_set = $opt_s; -$temp_dir = $opt_T || "/tmp"; +$temp_base = $opt_T || "/tmp"; if (defined $opt_t) { die "$prog: bad -t argument (should be number > 0): $opt_t\n" if $opt_t !~ /^\d+$/ || $opt_t <= 0; @@ -300,6 +299,18 @@ chop($pwd = `pwd 2>/dev/null`); die "$prog: couldn't get current working directory\n" if $pwd eq ''; die "$prog: couldn't cd to $pwd - $!\n" if !chdir($pwd); +die "$prog: couldn't cd to $temp_base - $!\n" if !chdir($temp_base); +die "$prog: couldn't get temporary directory base\n" unless -d '.'; +$temps = sprintf("chk%d-%d.", $$, time()); +$tempi = 0; +until (mkdir(($tempdir = sprintf("%s%03d", $temps, $tempi)), 0700)) { + die "$prog: couldn't get temporary directory\n" if $tempi++ >= 999; +} +die "$prog: couldn't cd to $tempdir - $!\n" if !chdir($tempdir); +chop($temp_dir = `pwd 2>/dev/null`); +die "$prog: couldn't get temporary directory\n" if $temp_dir eq ''; +die "$prog: couldn't cd to $pwd - $!\n" if !chdir($pwd); + if (!$program_kludge) { $test_prog = "$pwd/$test_prog" if substr($test_prog, 0, 1) ne '/'; die "$prog: $test_prog is not executable - bye\n" @@ -314,15 +325,12 @@ $SIG{'ALRM'} = 'catch_sigalrm'; $| = 1; # Create temp files -($fh, $temps) = mkstemp("${temp_dir}/rts.XXXXXXXX"); -close($fh); -($fh, $tempi) = mkstemp("${temp_dir}/rti.XXXXXXXX"); -close($fh); -($fh, $tempo) = mkstemp("${temp_dir}/rto.XXXXXXXX"); -close($fh); -($fh, $tempe) = mkstemp("${temp_dir}/rte.XXXXXXXX"); -close($fh); -$tempdir = mkdtemp("${temp_dir}/rtd.XXXXXXXX"); +$temps = "${temp_dir}/rts"; +$tempi = "${temp_dir}/rti"; +$tempo = "${temp_dir}/rto"; +$tempe = "${temp_dir}/rte"; +$tempdir = "${temp_dir}/rtd"; +mkdir($tempdir, 0700) or die "$prog: couldn't mkdir $tempdir - $!\n"; if (-d $test_set) { $file_prefix_skip = length($test_set) + 1; @@ -365,6 +373,7 @@ cleanup_exit unlink($tempi, $tempo, $tempe, $temps); &scrub_dir($tempdir) if defined $tempdir; rmdir($tempdir) if defined $tempdir; + rmdir($temp_dir) if defined $temp_dir; if ($sig) { $SIG{$sig} = 'DEFAULT';