Hello, I would like to propose the following two changes for fixin() function:
- make use of File::Temp in order to make .new and .bak
filenames less predicatble
- preserve mode and timestamps
The following patch is made against ExtUtils-MakeMaker-6.21 but
it also applies to bleadperl. I hope this makes sense.
--
Alexey Tourbin
ALT Linux Team
--- ExtUtils-MakeMaker-6.21/lib/ExtUtils/MM_Unix.pm~ 2003-11-11 08:04:14 +0000
+++ ExtUtils-MakeMaker-6.21/lib/ExtUtils/MM_Unix.pm 2004-09-09 02:05:13 +0000
@@ -1300,8 +1300,8 @@
my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
for my $file (@files) {
- my $file_new = "$file.new";
- my $file_bak = "$file.bak";
+
+ my @stat = stat($file);
local(*FIXIN);
local(*FIXOUT);
@@ -1354,6 +1354,10 @@
next;
}
+ require File::Temp;
+ my $file_new = File::Temp::mktemp("$file.new.XXXXXXXX");
+ my $file_bak = File::Temp::mktemp("$file.bak.XXXXXXXX");
+
unless ( open(FIXOUT,">$file_new") ) {
warn "Can't create new $file: $!\n";
next;
@@ -1366,8 +1370,6 @@
close FIXIN;
close FIXOUT;
- chmod 0666, $file_bak;
- unlink $file_bak;
unless ( rename($file, $file_bak) ) {
warn "Can't rename $file to $file_bak: $!";
next;
@@ -1381,6 +1383,8 @@
next;
}
unlink $file_bak;
+ chmod $stat[2] & 0777 => $file;
+ utime @stat[8,9] => $file;
} continue {
close(FIXIN) if fileno(FIXIN);
system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
pgpimRlDh1q2S.pgp
Description: PGP signature
